Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set(rscore_srcs
mm/buddy/checkpoint.c
mm/model_allocator.c
mm/msg_allocator.c
parallel/parallel.c
parallel/timewarp.c
serial/serial.c)

if(MPI_FOUND)
Expand Down
12 changes: 11 additions & 1 deletion src/ROOT-Sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ enum log_level {
LOG_SILENT //!< Emit no messages during the simulation.
};

enum synchronization_algorithm {
SERIAL = 1, //!< The simulation runs on the serial runtime
TIME_WARP, //!< The simulation runs using the optimistic Time Warp algorithm
};

/// A set of configurable values used by other modules
struct simulation_configuration {
/// The number of LPs to be used in the simulation
Expand All @@ -190,7 +195,12 @@ struct simulation_configuration {
unsigned ckpt_interval;
/// If set, worker threads are bound to physical cores
bool core_binding;
/// If set, the simulation will run on the serial runtime
/// Specify what synchronization algorithm we are using
enum synchronization_algorithm synchronization;
/**
* @deprecated since 3.1.0
* If set, the simulation will run on the serial runtime
*/
bool serial;
/// Function pointer to the dispatching function
ProcessEvent_t dispatcher;
Expand Down
2 changes: 1 addition & 1 deletion src/gvt/termination.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void termination_on_gvt(const simtime_t current_gvt)
*/
void RootsimStop(void)
{
if(global_config.serial) {
if(global_config.synchronization == SERIAL) {
global_config.termination_time = -1.0;
return;
}
Expand Down
32 changes: 24 additions & 8 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include <ROOT-Sim.h>

#include <inttypes.h>
#include <string.h>

/// A flag to check if the core library has been initialized correctly
Expand Down Expand Up @@ -54,22 +53,29 @@ static void print_config(void)
else
fprintf(stderr, "%lf\n", global_config.termination_time);

if(global_config.serial) {
fprintf(stderr, "Parallelism: sequential simulation\n");
} else {
switch (global_config.synchronization) {
case SERIAL:
fprintf(stderr, "Parallelism: sequential simulation\n");
break;
case TIME_WARP:
fprintf(stderr, "Parallelism: optimistic synchronization\n");
break;
}
if (global_config.synchronization != SERIAL) {
if(n_nodes > 1)
fprintf(stderr, "Parallelism: %d MPI processes\n", n_nodes);
else
fprintf(stderr, "Parallelism: %u threads\n", global_config.n_threads);
}

fprintf(stderr, "Thread-to-core binding: %s\n", global_config.core_binding ? "enabled" : "disabled");

fprintf(stderr, "GVT period: %u ms\n", global_config.gvt_period / 1000);

if(global_config.ckpt_interval) {
fprintf(stderr, "Checkpoint interval: %u events\n", global_config.ckpt_interval);
} else {
if(!global_config.serial)
if(global_config.synchronization != SERIAL)
fprintf(stderr, "Checkpoint interval: auto\n");
}

Expand Down Expand Up @@ -108,9 +114,19 @@ int RootsimInit(const struct simulation_configuration *conf)
return -1;
}

if (global_config.serial) {
fprintf(stderr, "Using the deprecated `serial` configuration flag. Please swith to `.synchronization = SERIAL` instead\n");
global_config.synchronization = SERIAL;
}

if (unlikely(global_config.synchronization == 0)) {
fprintf(stderr, "No synchronization algorithm specified.\n");
return -1;
}

log_init(global_config.logfile);

if(global_config.serial)
if(global_config.synchronization == SERIAL)
global_config.n_threads = 1;
else if(global_config.n_threads == 0)
global_config.n_threads = thread_cores_count();
Expand Down Expand Up @@ -138,15 +154,15 @@ int RootsimRun(void)
if(!configuration_done)
return -1;

if(!global_config.serial)
if(global_config.synchronization == TIME_WARP)
mpi_global_init(NULL, NULL);

if(global_config.log_level < LOG_SILENT && !rid) {
print_logo();
print_config();
}

if(global_config.serial) {
if(global_config.synchronization == SERIAL) {
ret = serial_simulation();
} else {
ret = parallel_simulation();
Expand Down
2 changes: 1 addition & 1 deletion src/lp/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static _Thread_local struct lp_msg *current_msg;
void ScheduleNewEvent(const lp_id_t receiver, const simtime_t timestamp, const unsigned event_type, const void *payload,
unsigned payload_size)
{
if(unlikely(global_config.serial)) {
if(unlikely(global_config.synchronization == SERIAL)) {
ScheduleNewEvent_serial(receiver, timestamp, event_type, payload, payload_size);
return;
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test_program_link_libraries(sync rscore)
# Integration tests
test_program(correctness_serial integration/correctness/serial.c integration/correctness/application.c integration/correctness/functions.c integration/correctness/output_256.c)
test_program_link_libraries(correctness_serial rscore)
test_program(correctness_parallel integration/correctness/parallel.c integration/correctness/application.c integration/correctness/functions.c integration/correctness/output_256.c)
test_program(correctness_parallel integration/correctness/timewarp.c integration/correctness/application.c integration/correctness/functions.c integration/correctness/output_256.c)
test_program_link_libraries(correctness_parallel rscore)
test_program(phold integration/phold.c)
test_program_link_libraries(phold rscore)
27 changes: 24 additions & 3 deletions test/core/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,24 @@ static struct simulation_configuration conf = {
.committed = NULL,
};

static const struct simulation_configuration no_synchronization = {
.lps = 1,
.dispatcher = DummyProcessEvent,
.committed = DummyCanEnd,
};

static const struct simulation_configuration valid_conf = {
.lps = 1,
.dispatcher = DummyProcessEvent,
.committed = DummyCanEnd,
.lps = 1,
.dispatcher = DummyProcessEvent,
.committed = DummyCanEnd,
.synchronization = TIME_WARP,
};

static const struct simulation_configuration deprecated_conf = {
.lps = 1,
.dispatcher = DummyProcessEvent,
.committed = DummyCanEnd,
.serial = true,
};

static int run_rootsim(_unused void *_)
Expand Down Expand Up @@ -62,6 +76,13 @@ int main(void)
test_xf("CanEnd not set", init_rootsim, &conf);
test_xf("Start simulation with no CanEnd", run_rootsim, NULL);

memcpy(&conf, &no_synchronization, sizeof(conf));
test_xf("No synchronization algorithm", init_rootsim, &conf);
test_xf("Start simulation with no synchronization algorithm", run_rootsim, NULL);

memcpy(&conf, &deprecated_conf, sizeof(conf));
test("Legacy serial flag", init_rootsim, &conf);

memcpy(&conf, &valid_conf, sizeof(conf));
test("Initialization", init_rootsim, &conf);
test("Dummy simulation", run_rootsim, NULL);
Expand Down
4 changes: 2 additions & 2 deletions test/gvt/termination.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ static bool DummyCanEnd(_unused lp_id_t lid, _unused const void *state)
}

static struct simulation_configuration serial_conf = {
.lps = 1, .dispatcher = DummyProcessEvent, .committed = DummyCanEnd, .serial = true};
.lps = 1, .dispatcher = DummyProcessEvent, .committed = DummyCanEnd, .synchronization = SERIAL};

static struct simulation_configuration parallel_conf = {
.lps = 1, .dispatcher = DummyProcessEvent, .committed = DummyCanEnd, .serial = false};
.lps = 1, .dispatcher = DummyProcessEvent, .committed = DummyCanEnd, .synchronization = TIME_WARP};

static int force_termination_test(void *conf)
{
Expand Down
2 changes: 1 addition & 1 deletion test/integration/correctness/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct simulation_configuration conf = {
.stats_file = NULL,
.ckpt_interval = 0,
.core_binding = false,
.serial = true,
.synchronization = SERIAL,
.dispatcher = ProcessEvent,
.committed = CanEnd,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct simulation_configuration conf = {
.stats_file = NULL,
.ckpt_interval = 0,
.core_binding = false,
.serial = false,
.synchronization = TIME_WARP,
.dispatcher = ProcessEvent,
.committed = CanEnd,
};
Expand Down
2 changes: 1 addition & 1 deletion test/integration/phold.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct simulation_configuration conf = {
.stats_file = "phold",
.ckpt_interval = 0,
.core_binding = true,
.serial = false,
.synchronization = TIME_WARP,
.dispatcher = ProcessEvent,
.committed = CanEnd,
};
Expand Down
1 change: 1 addition & 0 deletions test/log/rootsim_stats_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_stats_file(base_name, expected):
if float(match[i + 1]) == 0:
sys.exit(1)
elif expected_field != match[i + 1]:
print(f"Error in {base_name} at field {i + 1}: expected '{expected_field}', got '{match[i + 1]}'")
sys.exit(1)


Expand Down
2 changes: 1 addition & 1 deletion test/log/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static struct simulation_configuration conf = {
.stats_file = NULL,
.ckpt_interval = 0,
.core_binding = true,
.serial = false,
.synchronization = TIME_WARP,
.dispatcher = DummyProcessEvent,
.committed = DummyCanEnd,
};
Expand Down
Loading