Commit 28fc5583 authored by Millian Poquet's avatar Millian Poquet

CMakeLists.txt has been improved. README and TODO have been updated. Warning deletion in batsim.cpp

parent 807fbecd
#cmake_minimum_required(VERSION 2.8)
#Do we really need of 3.0.2 version ?
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 2.8)
#cmake_minimum_required(VERSION 3.0.2)
project("Batsim")
set(CMAKE_BUILD_TYPE Debug)
# C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Enable C11 or at least C99
#include(CheckCCompilerFlag)
#CHECK_C_COMPILER_FLAG("-std=c11" COMPILER_SUPPORTS_C11)
#CHECK_C_COMPILER_FLAG("-std=c99" COMPILER_SUPPORTS_C99)
#if(COMPILER_SUPPORTS_C11)
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
#elseif(COMPILER_SUPPORTS_C99)
# message(STATUS "The compiler ${CMAKE_C_COMPILER} has no C11 support. Using C99 instead.")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
#else()
# message(STATUS "The compiler ${CMAKE_C_COMPILER} has no C11 nor C99 support. Please update your C compiler.")
#endif()
# Dependencies
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++14")
## SimGrid dependency
find_package(SimGrid REQUIRED)
include_directories(${SIMGRID_INCLUDE_DIR})
## Boost dependency
find_package(Boost REQUIRED COMPONENTS system filesystem)
include_directories(${Boost_INCLUDE_DIR})
## Rapidjson dependency
find_package(rapidjson REQUIRED)
include_directories(${RAPIDJSON_INCLUDE_DIRS})
# Executables
add_executable(batsim batsim.cpp export.cpp ipp.cpp job_submitter.cpp jobs.cpp jobs_execution.cpp machines.cpp network.cpp profiles.cpp workload.cpp)
#add_executable(batexec batexec.c job.c utils.c export.c)
### Add definitions for compile
target_link_libraries(batsim simgrid boost_system boost_filesystem)
# Libraries to link
target_link_libraries(batsim ${SIMGRID_LIBRARIES} ${Boost_SYSTEM_LIBRARY_DEBUG} ${Boost_FILESYSTEM_LIBRARY_DEBUG})
#target_link_libraries(batexec simgrid jansson m)
## Add intall target
# Installation
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/batsim
#${CMAKE_CURRENT_BINARY_DIR}/batexec
DESTINATION bin)
# Extra compiler flags
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_property(TARGET batsim APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -g")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set_property(TARGET batsim APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -g")
else()
message("Compiler is unknown, warnings will NOT be added to it")
endif()
\ No newline at end of file
CC=clang
CFLAGS=-Wall -Wextra
LDFLAGS=-lsimgrid -lm -ljansson
all: batsim batexec
batsim: batsim.o job.o export.o machines.o utils.o
$(CC) -o $@ $^ $(LDFLAGS)
batexec: batexec.o job.o export.o machines.o utils.o
$(CC) -o $@ $^ $(LDFLAGS)
batsim.o: batsim.c batsim.h job.h export.h machines.h utils.h
$(CC) -o $@ -c $< $(CFLAGS)
batexec.o: batexec.c job.h utils.h
$(CC) -o $@ -c $< $(CFLAGS)
job.o: job.c job.h utils.h
$(CC) -o $@ -c $< $(CFLAGS)
export.o: export.c export.h job.h utils.h
$(CC) -o $@ -c $< $(CFLAGS)
machines.o: machines.c machines.h
$(CC) -o $@ -c $< $(CFLAGS)
utils.o: utils.c utils.h job.h
$(CC) -o $@ -c $< $(CFLAGS)
clean:
rm -f *.o
mrproper: clean
rm -f batsim batexec
distclean: mrproper
* Installation
* Installation
** dependencies
- simgrid (revision 2b7c35f960b4 on git://scm.gforge.inria.fr/simgrid/simgrid.git)
- Jansson: a C library for encoding, decoding and manipulating JSON data.
apt-get install libjansson4
apt-get install libjansson-dev
- simgrid (revision 8de23104635721196 on git://scm.gforge.inria.fr/simgrid/simgrid.git)
- rapidjson
- boost (system, filesystem)
- C++11 compiler
** first step: prepare Makefile
mkdir build
cd build
......@@ -16,16 +17,16 @@
** usage
*** test with fake scheduler
# open 2 terminal
# open 2 terminals
# first terminal
python fake_sched_uds.py workload_profiles/test_workload_profile.json
# second terminal
cd build
cd build
./batsim ../platforms/small_platform.xml ../workload_profiles/test_workload_profile.json
# second terminal
python filler_sched.py workload_profiles/test_workload_profile.json
*** test with oar core scheduler
# install
# install
git clone https://gforge.inria.fr/git/oar/oar-kao.git
git clone https://gforge.inria.fr/git/oar/python-oar-lib.git
......
* TODO energy
* TODO file I/O
* TODO smpi profile
* TODO evolving/moldable/malleable job support
* TODO VM
* TODO support for job creation during simulation
......@@ -9,8 +8,9 @@
* TODO shared nodes
* TODO node sleep/wakeup
* DONE smpi profile
* DONE msg_par_homogenous profile
* DONE job composed of sequence of profile [1, 5, 5 ]
* DONE job composed of sequence of profile [1, 5, 5]
* DONE delay job profile
* DONE profile composed
* DONE (VITE ISSUE) improve the Pajé trace generation (there are warnings when the trace are opened via vite)
......@@ -151,7 +151,7 @@ int main(int argc, char * argv[])
const Machine * masterMachine = context.machines.masterMachine();
context.machines.setTracer(&context.tracer);
context.tracer.initialize(&context, MSG_get_clock());
XBT_INFO("Machines created successfully. There are %d computing machines.", context.machines.machines().size());
XBT_INFO("Machines created successfully. There are %lu computing machines.", context.machines.machines().size());
// Socket
context.socket.create_socket(mainArgs.socketFilename);
......
# Try fo find Simgrid:
# SIMGRID_FOUND
# SIMGRID_INCLUDE_DIRS
# SIMGRID_LIBRARIES
# SIMGRID_DEFINITIONS
message("-- Looking for simgrid.h")
find_path(SIMGRID_INCLUDE_DIR
NAMES simgrid.h
HINTS ENV SIMGRID_PATH ENV INCLUDE ENV CPATH
PATHS /opt/simgrid /opt/Simgrid
PATH_SUFFIXES include)
message("-- Looking for simgrid.h - ${SIMGRID_INCLUDE_DIR}")
message("-- Looking for libsimgrid")
find_library(SIMGRID_LIBRARY
NAMES simgrid
HINTS ENV SIMGRID_PATH ENV LIBRARY_PATH
PATHS /opt/simgrid /opt/Simgrid
PATH_SUFFIXES lib)
message("-- Looking for libsimgrid -- ${SIMGRID_LIBRARY}")
set(SIMGRID_LIBRARIES ${SIMGRID_LIBRARY} )
set(SIMGRID_INCLUDE_DIRS ${SIMGRID_INCLUDE_DIR} )
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SimGrid DEFAULT_MSG
SIMGRID_LIBRARY SIMGRID_INCLUDE_DIR)
mark_as_advanced(SIMGRID_INCLUDE_DIR SIMGRID_LIBRARY)
\ No newline at end of file
# Copyright (c) 2011 Milo Yip (miloyip@gmail.com)
# Copyright (c) 2013 Rafal Jeczalik (rjeczalik@gmail.com)
# Distributed under the MIT License (see license.txt file)
# -----------------------------------------------------------------------------------
#
# Finds the rapidjson library
#
# -----------------------------------------------------------------------------------
#
# Variables used by this module, they can change the default behaviour.
# Those variables need to be either set before calling find_package
# or exported as environment variables before running CMake:
#
# RAPIDJSON_INCLUDEDIR - Set custom include path, useful when rapidjson headers are
# outside system paths
# RAPIDJSON_USE_SSE2 - Configure rapidjson to take advantage of SSE2 capabilities
# RAPIDJSON_USE_SSE42 - Configure rapidjson to take advantage of SSE4.2 capabilities
#
# -----------------------------------------------------------------------------------
#
# Variables defined by this module:
#
# RAPIDJSON_FOUND - True if rapidjson was found
# RAPIDJSON_INCLUDE_DIRS - Path to rapidjson include directory
# RAPIDJSON_CXX_FLAGS - Extra C++ flags required for compilation with rapidjson
#
# -----------------------------------------------------------------------------------
#
# Example usage:
#
# set(RAPIDJSON_USE_SSE2 ON)
# set(RAPIDJSON_INCLUDEDIR "/opt/github.com/rjeczalik/rapidjson/include")
#
# find_package(rapidjson REQUIRED)
#
# include_directories("${RAPIDJSON_INCLUDE_DIRS}")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RAPIDJSON_CXX_FLAGS}")
# add_executable(foo foo.cc)
#
# -----------------------------------------------------------------------------------
foreach(opt RAPIDJSON_INCLUDEDIR RAPIDJSON_USE_SSE2 RAPIDJSON_USE_SSE42)
if(${opt} AND DEFINED ENV{${opt}} AND NOT ${opt} STREQUAL "$ENV{${opt}}")
message(WARNING "Conflicting ${opt} values: ignoring environment variable and using CMake cache entry.")
elseif(DEFINED ENV{${opt}} AND NOT ${opt})
set(${opt} "$ENV{${opt}}")
endif()
endforeach()
find_path(
RAPIDJSON_INCLUDE_DIRS
NAMES rapidjson/rapidjson.h
PATHS ${RAPIDJSON_INCLUDEDIR}
DOC "Include directory for the rapidjson library."
)
mark_as_advanced(RAPIDJSON_INCLUDE_DIRS)
if(RAPIDJSON_INCLUDE_DIRS)
set(RAPIDJSON_FOUND TRUE)
endif()
mark_as_advanced(RAPIDJSON_FOUND)
if(RAPIDJSON_USE_SSE42)
set(RAPIDJSON_CXX_FLAGS "-DRAPIDJSON_SSE42")
if(MSVC)
set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} /arch:SSE4.2")
else()
set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} -msse4.2")
endif()
else()
if(RAPIDJSON_USE_SSE2)
set(RAPIDJSON_CXX_FLAGS "-DRAPIDJSON_SSE2")
if(MSVC)
set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} /arch:SSE2")
else()
set(RAPIDJSON_CXX_FLAGS "${RAPIDJSON_CXX_FLAGS} -msse2")
endif()
endif()
endif()
mark_as_advanced(RAPIDJSON_CXX_FLAGS)
if(RAPIDJSON_FOUND)
if(NOT rapidjson_FIND_QUIETLY)
message(STATUS "Found rapidjson header files in ${RAPIDJSON_INCLUDE_DIRS}")
if(DEFINED RAPIDJSON_CXX_FLAGS)
message(STATUS "Found rapidjson C++ extra compilation flags: ${RAPIDJSON_CXX_FLAGS}")
endif()
endif()
elseif(rapidjson_FIND_REQUIRED)
message(FATAL_ERROR "Could not find rapidjson")
else()
message(STATUS "Optional package rapidjson was not found")
endif()
import struct
import socket
import sys
import os
import json
from random import sample
def create_uds(uds_name):
# Make sure the socket does not already exist
try:
os.unlink(uds_name)
except OSError:
if os.path.exists(uds_name):
raise
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# Bind the socket to the port
print >>sys.stderr, 'starting up on %s' % uds_name
sock.bind(uds_name)
# Listen for incoming connections
sock.listen(1)
return sock
def read_bat_msg(connection):
lg_str = connection.recv(4)
if not lg_str:
print "connection is closed by batsim core"
exit(1)
#print 'from client (lg_str): %r' % lg_str
lg = struct.unpack("i",lg_str)[0]
#print 'size msg to recv %d' % lg
msg = connection.recv(lg)
print 'from batsim : %r' % msg
sub_msgs = msg.split('|')
data = sub_msgs[0].split(":")
version = int(data[0])
now = float(data[1])
print "version: ", version, " now: ", now
jobs_submitted = []
new_jobs_completed = []
for i in range(1, len(sub_msgs)):
data = sub_msgs[i].split(':')
if data[1] == 'S':
jobs_submitted.append( int(data[2]) )
elif data[1] == 'C':
new_jobs_completed.append(int(data[2]))
else:
raise Exception("Unknow submessage type" + data[1] )
return (now, jobs_submitted, new_jobs_completed)
def send_bat_msg(connection, now, jids_toLaunch, jobs):
msg = "0:" + str(now) + "|"
if jids_toLaunch:
msg += str(now) + ":J:"
for jid in jids_toLaunch:
msg += str(jid) + "="
for r in jobs[jid]:
msg += str(r) + ","
msg = msg[:-1] + ";" # replace last comma by semicolon separtor between jobs
msg = msg[:-1] # remove last semicolon
else: #Do nothing
msg += str(now) +":N"
print msg
lg = struct.pack("i",int(len(msg)))
connection.sendall(lg)
connection.sendall(msg)
def load_json_workload_profile(filename):
wkp_file = open(filename)
wkp = json.load(wkp_file)
return wkp["jobs"], wkp["nb_res"]
###
#
#
server_address = '/tmp/bat_socket'
json_jobs, nb_res = load_json_workload_profile(sys.argv[1])
print "nb_res", nb_res
jobs_res_req = { j["id"]: j["res"] for j in json_jobs}
nb_jobs = len(jobs_res_req)
print "nb_jobs", nb_jobs
nb_completed_jobs = 0
jobs_res = {}
jobs_completed = []
jobs_waiting = []
sched_delay = 5.0
##
# uds creation and waiting for connection
#
sock = create_uds(server_address)
print "waiting for a connection"
connection, client_address = sock.accept()
while nb_completed_jobs < nb_jobs:
# read from uds
now_str, jobs_submitted, new_jobs_completed = read_bat_msg(connection)
# fake scheduler
for job_id in jobs_submitted:
#
# always schedule jobs !
# random resources assignment !
#
nb_res_req = jobs_res_req[job_id]
res = sample(range(nb_res), nb_res_req)
jobs_res[job_id] = res
# update time
now = float(now_str) + sched_delay
# send to uds
send_bat_msg(connection, now, jobs_submitted, jobs_res)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment