本文整理汇总了C++中MSG_task_create函数的典型用法代码示例。如果您正苦于以下问题:C++ MSG_task_create函数的具体用法?C++ MSG_task_create怎么用?C++ MSG_task_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MSG_task_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: master
/** Emitter function */
int master(int argc, char *argv[])
{
double task_comp_size = 5E7;
double task_comm_size = 1E6;
char mailbox[256];
msg_task_t task = NULL;
msg_host_t jupiter = MSG_get_host_by_name("Jupiter");
sprintf(mailbox, "jupi");
task = MSG_task_create("task on", task_comp_size, task_comm_size, NULL);
XBT_INFO("Sending \"%s\"", task->name);
if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK)
MSG_task_destroy(task);
MSG_process_sleep(1);
MSG_host_off(jupiter);
task = MSG_task_create("task off", task_comp_size, task_comm_size, NULL);
XBT_INFO("Sending \"%s\"", task->name);
if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK)
MSG_task_destroy(task);
MSG_host_on(jupiter);
xbt_swag_t jupi_processes = MSG_host_get_process_list(jupiter);
void *process;
xbt_swag_foreach(process, jupi_processes) {
MSG_process_kill(process);
}
开发者ID:FlorianPO,项目名称:simgrid,代码行数:30,代码来源:host_on_off.c
示例2: master
int master(int argc, char *argv[])
{
const char *hostname = MSG_host_get_name(MSG_host_self());
int i;
//the hostname has an empty HDD with a capacity of 100000 (bytes)
TRACE_host_variable_set(hostname, "HDD_capacity", 100000);
TRACE_host_variable_set(hostname, "HDD_utilization", 0);
for (i = 0; i < 10; i++) {
//create and execute a task just to make the simulated time advance
msg_task_t task = MSG_task_create("task", 10000, 0, NULL);
MSG_task_execute (task);
MSG_task_destroy (task);
//ADD: after the execution of this task, the HDD utilization increases by 100 (bytes)
TRACE_host_variable_add(hostname, "HDD_utilization", 100);
}
for (i = 0; i < 10; i++) {
//create and execute a task just to make the simulated time advance
msg_task_t task = MSG_task_create("task", 10000, 0, NULL);
MSG_task_execute (task);
MSG_task_destroy (task);
//SUB: after the execution of this task, the HDD utilization decreases by 100 (bytes)
TRACE_host_variable_sub(hostname, "HDD_utilization", 100);
}
return 0;
}
开发者ID:FlorianPO,项目名称:simgrid,代码行数:30,代码来源:user_variables.c
示例3: master
/** Emitter function */
int master(int argc, char *argv[])
{
long number_of_tasks = atol(argv[1]);
long slaves_count = atol(argv[4]);
int i;
for (i = 0; i < number_of_tasks; i++) {
m_task_t task = NULL;
//creating task and setting its category
if (i % 2) {
task = MSG_task_create("task_compute", 10000000, 0, NULL);
TRACE_msg_set_task_category(task, "compute");
} else if (i % 3) {
task = MSG_task_create("task_request", 10, 10, NULL);
TRACE_msg_set_task_category(task, "request");
} else {
task = MSG_task_create("task_data", 10, 10000000, NULL);
TRACE_msg_set_task_category(task, "data");
}
MSG_task_send(task, "master_mailbox");
}
for (i = 0; i < slaves_count; i++) {
m_task_t finalize = MSG_task_create("finalize", 0, 1000, 0);
TRACE_msg_set_task_category(finalize, "finalize");
MSG_task_send(finalize, "master_mailbox");
}
return 0;
}
开发者ID:rosacris,项目名称:simgrid,代码行数:32,代码来源:categories.c
示例4: master
static int master(int argc, char *argv[])
{
long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
long workers_count = xbt_str_parse_int(argv[4], "Invalid amount of workers: %s");
for (int i = 0; i < number_of_tasks; i++) {
msg_task_t task = NULL;
/* creating task and setting its category */
if (i % 2) {
task = MSG_task_create("task_compute", 10000000, 0, NULL);
MSG_task_set_category(task, "compute");
} else if (i % 3) {
task = MSG_task_create("task_request", 10, 10, NULL);
MSG_task_set_category(task, "request");
} else {
task = MSG_task_create("task_data", 10, 10000000, NULL);
MSG_task_set_category(task, "data");
}
MSG_task_send(task, "master_mailbox");
}
for (int i = 0; i < workers_count; i++) {
msg_task_t finalize = MSG_task_create("finalize", 0, 1000, 0);
MSG_task_set_category(finalize, "finalize");
MSG_task_send(finalize, "master_mailbox");
}
return 0;
}
开发者ID:mpoquet,项目名称:simgrid,代码行数:30,代码来源:trace-categories.c
示例5: execute_load_test
static int execute_load_test(int argc, char* argv[])
{
msg_host_t host = MSG_host_by_name("MyHost1");
XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0)",
MSG_host_get_speed(host), sg_host_get_computed_flops(host));
double start = MSG_get_clock();
XBT_INFO("Sleep for 10 seconds");
MSG_process_sleep(10);
XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
"changed)",
MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
// Run a task
start = MSG_get_clock();
msg_task_t task1 = MSG_task_create("t1", 100E6, 0, NULL);
XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
MSG_task_execute(task1);
MSG_task_destroy(task1);
XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
"far: %.0E",
MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
// ========= Change power peak =========
int pstate = 2;
sg_host_set_pstate(host, pstate);
XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
MSG_host_get_power_peak_at(host, pstate), MSG_host_get_speed(host));
// Run a second task
start = MSG_get_clock();
task1 = MSG_task_create("t2", 100E6, 0, NULL);
XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
MSG_task_execute(task1);
MSG_task_destroy(task1);
XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
"far: %.0E",
MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
start = MSG_get_clock();
XBT_INFO("========= Requesting a reset of the computation counter");
sg_host_load_reset(host);
XBT_INFO("Sleep for 4 seconds");
MSG_process_sleep(4);
XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
// =========== Turn the other host off ==========
XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far.",
MSG_host_get_computed_flops(MSG_host_by_name("MyHost2")));
MSG_host_off(MSG_host_by_name("MyHost2"));
start = MSG_get_clock();
MSG_process_sleep(10);
XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
return 0;
}
开发者ID:simgrid,项目名称:simgrid,代码行数:60,代码来源:plugin-hostload.c
示例6: computation_fun
int computation_fun(int argc, char *argv[])
{
const char *pr_name = MSG_process_get_name(MSG_process_self());
const char *host_name = MSG_host_get_name(MSG_host_self());
double clock_sta, clock_end;
atask = MSG_task_create("Task1", 1e9, 1e9, NULL);
clock_sta = MSG_get_clock();
XBT_INFO("%s:%s task 1 created %g", host_name, pr_name, clock_sta);
MSG_task_execute(atask);
clock_end = MSG_get_clock();
XBT_INFO("%s:%s task 1 executed %g", host_name, pr_name, clock_end - clock_sta);
MSG_task_destroy(atask);
atask = NULL;
MSG_process_sleep(1);
atask = MSG_task_create("Task2", 1e10, 1e10, NULL);
clock_sta = MSG_get_clock();
XBT_INFO("%s:%s task 2 created %g", host_name, pr_name, clock_sta);
MSG_task_execute(atask);
clock_end = MSG_get_clock();
XBT_INFO("%s:%s task 2 executed %g", host_name, pr_name, clock_end - clock_sta);
MSG_task_destroy(atask);
atask = NULL;
return 0;
}
开发者ID:Misirlou,项目名称:Interference-aware-scheduler,代码行数:32,代码来源:test.c
示例7: master
/** Emitter function */
int master(int argc, char *argv[])
{
long number_of_tasks = atol(argv[1]);
double task_comp_size = atof(argv[2]);
double task_comm_size = atof(argv[3]);
long slaves_count = atol(argv[4]);
XBT_INFO("master %ld %f %f %ld", number_of_tasks, task_comp_size,
task_comm_size, slaves_count);
int i;
for (i = 0; i < number_of_tasks; i++) {
char task_name[100];
snprintf (task_name, 100, "task-%d", i);
m_task_t task = NULL;
task = MSG_task_create(task_name, task_comp_size, task_comm_size, NULL);
//setting the category of task to "compute"
//the category of a task must be defined before it is sent or executed
TRACE_msg_set_task_category(task, "compute");
MSG_task_send(task, "master_mailbox");
}
for (i = 0; i < slaves_count; i++) {
char task_name[100];
snprintf (task_name, 100, "task-%d", i);
m_task_t finalize = MSG_task_create(task_name, 0, 0, xbt_strdup("finalize"));
TRACE_msg_set_task_category(finalize, "finalize");
MSG_task_send(finalize, "master_mailbox");
}
return 0;
}
开发者ID:rosacris,项目名称:simgrid,代码行数:33,代码来源:tasks.c
示例8: master
static int master(int argc, char *argv[])
{
long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s");
long workers_count = xbt_str_parse_int(argv[4], "Invalid amount of workers: %s");
//setting the variable "is_master" (previously declared) to value 1
TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "is_master", 1);
TRACE_mark("msmark", "start_send_tasks");
for (int i = 0; i < number_of_tasks; i++) {
msg_task_t task = NULL;
task = MSG_task_create("task", task_comp_size, task_comm_size, NULL);
//setting the variable "task_creation" to value i
TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "task_creation", i);
//setting the category of task to "compute"
//the category of a task must be defined before it is sent or executed
MSG_task_set_category(task, "compute");
MSG_task_send(task, "master_mailbox");
}
TRACE_mark("msmark", "finish_send_tasks");
for (int i = 0; i < workers_count; i++) {
msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
MSG_task_set_category(finalize, "finalize");
MSG_task_send(finalize, "master_mailbox");
}
return 0;
}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:33,代码来源:trace-masterworker.c
示例9: master
/** Emitter function */
int master(int argc, char *argv[])
{
long number_of_tasks = atol(argv[1]);
double task_comp_size = atof(argv[2]);
double task_comm_size = atof(argv[3]);
long slaves_count = atol(argv[4]);
//setting the variable "is_master" (previously declared) to value 1
TRACE_host_variable_set("is_master", 1);
TRACE_mark("msmark", "start_send_tasks");
int i;
for (i = 0; i < number_of_tasks; i++) {
m_task_t task = NULL;
task = MSG_task_create("task", task_comp_size, task_comm_size, NULL);
//setting the variable "task_creation" to value i
TRACE_host_variable_set("task_creation", i);
//setting the category of task to "compute"
//the category of a task must be defined before it is sent or executed
TRACE_msg_set_task_category(task, "compute");
MSG_task_send(task, "master_mailbox");
}
TRACE_mark("msmark", "finish_send_tasks");
for (i = 0; i < slaves_count; i++) {
m_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
TRACE_msg_set_task_category(finalize, "finalize");
MSG_task_send(finalize, "master_mailbox");
}
return 0;
}
开发者ID:rosacris,项目名称:simgrid,代码行数:35,代码来源:ms.c
示例10: coordinator
static int coordinator(int argc, char *argv[])
{
int CS_used = 0; // initially the CS is idle
while (1) {
msg_task_t task = NULL;
MSG_task_receive(&task, "coordinator");
const char *kind = MSG_task_get_name(task); //is it a request or a release?
if (!strcmp(kind, "request")) { // that's a request
char *req = MSG_task_get_data(task);
if (CS_used) {
XBT_INFO("CS already used.");
msg_task_t answer = MSG_task_create("not grant", 0, 1000, NULL);
MSG_task_send(answer, req);
} else { // can serve it immediately
XBT_INFO("CS idle. Grant immediately");
msg_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
MSG_task_send(answer, req);
CS_used = 1;
}
} else { // that's a release. Check if someone was waiting for the lock
XBT_INFO("CS release. resource now idle");
CS_used = 0;
}
MSG_task_destroy(task);
kind = NULL;
}
return 0;
}
开发者ID:mpoquet,项目名称:simgrid,代码行数:30,代码来源:bugged2_liveness.c
示例11: master
/** Emitter function */
int master(int argc, char *argv[])
{
int i;
for (i = 1; i <= number_of_jobs; i++) {
char mailbox[256];
char sprintf_buffer[256];
msg_task_t task = NULL;
sprintf(mailbox, "slave-%ld", i % number_of_slaves);
sprintf(sprintf_buffer, "Task_%d", i);
task =
MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
NULL);
XBT_DEBUG("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name,
number_of_jobs, mailbox);
MSG_task_send(task, mailbox);
}
XBT_DEBUG
("All tasks have been dispatched. Let's tell everybody the computation is over.");
for (i = 0; i < number_of_slaves; i++) {
char mailbox[80];
sprintf(mailbox, "slave-%ld", i % number_of_slaves);
msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
MSG_task_send(finalize, mailbox);
}
XBT_DEBUG("Goodbye now!");
return 0;
} /* end_of_master */
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:34,代码来源:masterslave_arg.c
示例12: server
static int server(int argc, char *argv[])
{
msg_task_t task = MSG_task_create("a", 0, 0, (char*)"Some data");
MSG_task_isend(task, "mailbox");
xbt_assert(MSG_task_listen("mailbox")); // True (1)
XBT_INFO("Task listen works on regular mailboxes");
task = NULL;
MSG_task_receive(&task, "mailbox");
xbt_assert(!strcmp("Some data", MSG_task_get_data(task)), "Data received: %s", (char*)MSG_task_get_data(task));
MSG_task_destroy(task);
XBT_INFO("Data successfully received from regular mailbox");
MSG_mailbox_set_async("mailbox2");
task = MSG_task_create("b", 0, 0, (char*)"More data");
MSG_task_isend(task, "mailbox2");
xbt_assert(MSG_task_listen("mailbox2")); // used to break.
XBT_INFO("Task listen works on asynchronous mailboxes");
task = NULL;
MSG_task_receive(&task, "mailbox2");
xbt_assert(!strcmp("More data", MSG_task_get_data(task)));
MSG_task_destroy(task);
XBT_INFO("Data successfully received from asynchronous mailbox");
return 0;
}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:27,代码来源:listen_async.c
示例13: sender
/** Sender function */
int sender(int argc, char *argv[])
{
long number_of_tasks = atol(argv[1]);
double task_comp_size = atof(argv[2]);
double task_comm_size = atof(argv[3]);
long receivers_count = atol(argv[4]);
double sleep_start_time = atof(argv[5]);
double sleep_test_time = atof(argv[6]);
XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time,
sleep_test_time);
msg_comm_t comm = NULL;
int i;
m_task_t task = NULL;
MSG_process_sleep(sleep_start_time);
for (i = 0; i < number_of_tasks; i++) {
char mailbox[256];
char sprintf_buffer[256];
sprintf(mailbox, "receiver-%ld", i % receivers_count);
sprintf(sprintf_buffer, "Task_%d", i);
task =
MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
NULL);
comm = MSG_task_isend(task, mailbox);
XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
if (sleep_test_time == 0) {
MSG_comm_wait(comm, -1);
} else {
while (MSG_comm_test(comm) == 0) {
MSG_process_sleep(sleep_test_time);
};
MSG_comm_destroy(comm);
}
}
for (i = 0; i < receivers_count; i++) {
char mailbox[80];
sprintf(mailbox, "receiver-%ld", i % receivers_count);
task = MSG_task_create("finalize", 0, 0, 0);
comm = MSG_task_isend(task, mailbox);
XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
if (sleep_test_time == 0) {
MSG_comm_wait(comm, -1);
} else {
while (MSG_comm_test(comm) == 0) {
MSG_process_sleep(sleep_test_time);
};
MSG_comm_destroy(comm);
}
}
XBT_INFO("Goodbye now!");
return 0;
} /* end_of_sender */
开发者ID:rosacris,项目名称:simgrid,代码行数:61,代码来源:peer.c
示例14: sender
/* Sender process expects 6 arguments: */
static int sender(int argc, char *argv[])
{
long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); /* - number of tasks */
double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); /* - computational cost */
double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /* - communication cost */
long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s"); /* - number of receivers */
double sleep_start_time = xbt_str_parse_double(argv[5], "Invalid sleep start time: %s"); /* - start time */
double sleep_test_time = xbt_str_parse_double(argv[6], "Invalid test time: %s"); /* - test time */
XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time);
int i;
msg_task_t task = NULL;
msg_comm_t comm = NULL;
MSG_process_sleep(sleep_start_time);
for (i = 0; i < number_of_tasks; i++) {
char mailbox[256];
char snprintf_buffer[256];
snprintf(mailbox,255, "receiver-%ld", i % receivers_count);
snprintf(snprintf_buffer,255, "Task_%d", i);
/* This process first creates a task and send it asynchronously with @ref MSG_task_isend. Then, if: */
task = MSG_task_create(snprintf_buffer, task_comp_size, task_comm_size, NULL);
comm = MSG_task_isend(task, mailbox);
XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
if (sleep_test_time > 0) { /* - "test_time" is set to 0, wait on @ref MSG_comm_wait */
while (MSG_comm_test(comm) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */
MSG_process_sleep(sleep_test_time);
};
} else {
MSG_comm_wait(comm, -1);
}
MSG_comm_destroy(comm);
}
for (i = 0; i < receivers_count; i++) {
char mailbox[80];
snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
task = MSG_task_create("finalize", 0, 0, 0);
comm = MSG_task_isend(task, mailbox);
XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
if (sleep_test_time > 0) {
while (MSG_comm_test(comm) == 0) {
MSG_process_sleep(sleep_test_time);
}
} else {
MSG_comm_wait(comm, -1);
}
MSG_comm_destroy(comm);
}
XBT_INFO("Goodbye now!");
return 0;
}
开发者ID:luizabeltrame,项目名称:simgrid,代码行数:57,代码来源:async-wait.c
示例15: action_reduce
static void action_reduce(const char *const *action)
{
int i;
char *reduce_identifier;
char mailbox[80];
double comm_size = parse_double(action[2]);
double comp_size = parse_double(action[3]);
msg_task_t comp_task = NULL;
const char *process_name;
double clock = MSG_get_clock();
process_globals_t counters =
(process_globals_t) MSG_process_get_data(MSG_process_self());
xbt_assert(communicator_size, "Size of Communicator is not defined, "
"can't use collective operations");
process_name = MSG_process_get_name(MSG_process_self());
reduce_identifier = bprintf("reduce_%d", counters->reduce_counter++);
if (!strcmp(process_name, "p0")) {
XBT_DEBUG("%s: %s is the Root", reduce_identifier, process_name);
msg_comm_t *comms = xbt_new0(msg_comm_t, communicator_size - 1);
msg_task_t *tasks = xbt_new0(msg_task_t, communicator_size - 1);
for (i = 1; i < communicator_size; i++) {
sprintf(mailbox, "%s_p%d_p0", reduce_identifier, i);
comms[i - 1] = MSG_task_irecv(&(tasks[i - 1]), mailbox);
}
MSG_comm_waitall(comms, communicator_size - 1, -1);
for (i = 1; i < communicator_size; i++) {
MSG_comm_destroy(comms[i - 1]);
MSG_task_destroy(tasks[i - 1]);
}
xbt_free(comms);
xbt_free(tasks);
comp_task = MSG_task_create("reduce_comp", comp_size, 0, NULL);
XBT_DEBUG("%s: computing 'reduce_comp'", reduce_identifier);
MSG_task_execute(comp_task);
MSG_task_destroy(comp_task);
XBT_DEBUG("%s: computed", reduce_identifier);
} else {
XBT_DEBUG("%s: %s sends", reduce_identifier, process_name);
sprintf(mailbox, "%s_%s_p0", reduce_identifier, process_name);
XBT_DEBUG("put on %s", mailbox);
MSG_task_send(MSG_task_create(reduce_identifier, 0, comm_size, NULL),
mailbox);
}
log_action(action, MSG_get_clock() - clock);
xbt_free(reduce_identifier);
}
开发者ID:tempbottle,项目名称:simgrid,代码行数:55,代码来源:actions.c
示例16: dvfs
int dvfs(int argc, char *argv[])
{
msg_host_t host = NULL;
msg_task_t task1 = NULL;
double task_time = 0;
host = MSG_get_host_by_name("MyHost1");
double current_peak = MSG_get_host_current_power_peak(host);
XBT_INFO("Current power peak=%lf", current_peak);
double consumed_energy = MSG_get_host_consumed_energy(host);
XBT_INFO("Total energy (Joules): %lf", consumed_energy);
// Run a task
task1 = MSG_task_create ("t1", 100E6, 0, NULL);
MSG_task_execute (task1);
MSG_task_destroy(task1);
task_time = MSG_get_clock();
XBT_INFO("Task1 simulation time: %le", task_time);
consumed_energy = MSG_get_host_consumed_energy(host);
XBT_INFO("Total energy (Joules): %lf", consumed_energy);
// ========= Change power peak =========
int peak_index=2;
double peak_at = MSG_get_host_power_peak_at(host, peak_index);
XBT_INFO("=========Changing power peak value to %lf (at index %d)", peak_at, peak_index);
MSG_set_host_power_peak_at(host, peak_index);
// Run a second task
task1 = MSG_task_create ("t2", 100E6, 0, NULL);
MSG_task_execute (task1);
MSG_task_destroy(task1);
task_time = MSG_get_clock() - task_time;
XBT_INFO("Task2 simulation time: %le", task_time);
consumed_energy = MSG_get_host_consumed_energy(host);
XBT_INFO("Total energy (Joules): %lf", consumed_energy);
MSG_process_sleep(3);
task_time = MSG_get_clock() - task_time;
XBT_INFO("Task3 (sleep) simulation time: %le", task_time);
consumed_energy = MSG_get_host_consumed_energy(host);
XBT_INFO("Total energy (Joules): %lf", consumed_energy);
return 0;
}
开发者ID:cemsbr,项目名称:simgrid,代码行数:53,代码来源:e2.c
示例17: client
static int client(int argc, char *argv[])
{
int my_pid = MSG_process_get_PID(MSG_process_self());
char *my_mailbox = xbt_strdup(argv[1]);
msg_task_t grant = NULL, release = NULL;
while(1){
XBT_INFO("Ask the request");
MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox), "coordinator");
if(strcmp(my_mailbox, "1") == 0){
r = 1;
cs = 0;
XBT_INFO("Propositions changed : r=1, cs=0");
}
MSG_task_receive(&grant, my_mailbox);
const char *kind = MSG_task_get_name(grant);
if((strcmp(my_mailbox, "1") == 0) && (strcmp("grant", kind) == 0)){
cs = 1;
r = 0;
XBT_INFO("Propositions changed : r=0, cs=1");
}
MSG_task_destroy(grant);
grant = NULL;
kind = NULL;
XBT_INFO("%s got the answer. Sleep a bit and release it", argv[1]);
MSG_process_sleep(1);
release = MSG_task_create("release", 0, 1000, NULL);
MSG_task_send(release, "coordinator");
release = NULL;
MSG_process_sleep(my_pid);
if(strcmp(my_mailbox, "1") == 0){
cs=0;
r=0;
XBT_INFO("Propositions changed : r=0, cs=0");
}
}
return 0;
}
开发者ID:glesserd,项目名称:simgrid,代码行数:50,代码来源:bugged1_liveness.c
示例18: dvfs
static int dvfs(int argc, char* argv[])
{
double workload = 100E6;
msg_host_t host = MSG_host_self();
int nb = MSG_host_get_nb_pstates(host);
XBT_INFO("Count of Processor states=%d", nb);
double current_peak = MSG_host_get_speed(host);
XBT_INFO("Current power peak=%f", current_peak);
// Run a task
msg_task_t task1 = MSG_task_create("t1", workload, 0, NULL);
MSG_task_execute(task1);
MSG_task_destroy(task1);
double task_time = MSG_get_clock();
XBT_INFO("Task1 simulation time: %e", task_time);
// Change power peak
int new_pstate = 2;
xbt_assert(new_pstate < nb, "Cannot set the host %s at pstate %d because it only provides %d pstates.",
MSG_host_get_name(host), new_pstate, nb);
double peak_at = MSG_host_get_power_peak_at(host, new_pstate);
XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_pstate);
MSG_host_set_pstate(host, new_pstate);
current_peak = MSG_host_get_speed(host);
XBT_INFO("Current power peak=%f", current_peak);
// Run a second task
task1 = MSG_task_create("t1", workload, 0, NULL);
MSG_task_execute(task1);
MSG_task_destroy(task1);
task_time = MSG_get_clock() - task_time;
XBT_INFO("Task2 simulation time: %e", task_time);
// Verify the default pstate is set to 0
host = MSG_host_by_name("MyHost2");
int nb2 = MSG_host_get_nb_pstates(host);
XBT_INFO("Count of Processor states=%d", nb2);
double current_peak2 = MSG_host_get_speed(host);
XBT_INFO("Current power peak=%f", current_peak2);
return 0;
}
开发者ID:mpoquet,项目名称:simgrid,代码行数:49,代码来源:energy-pstate.c
示例19: client
int client(int argc, char *argv[])
{
msg_task_t task1 =
MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
msg_task_t task2 =
MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
XBT_INFO("Send %d!", atoi(argv[1]));
MSG_task_send(task1, "mymailbox");
XBT_INFO("Send %d!", atoi(argv[1]));
MSG_task_send(task2, "mymailbox");
return 0;
}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:15,代码来源:bugged2.c
示例20: send_task
// this function permit to send to the node "mailbox" the task number i
void send_task(int i, char * mailbox, char * myMailbox) {
msg_task_t task = NULL;
char task_name[TASK_NAME_SIZE];
struct clientDataTask * data = (struct clientDataTask *) malloc(sizeof(struct clientDataTask));
//printf("%s: I send a request to %s\n", myMailbox, mailbox);
sprintf(task_name, "task-%d", i);
strcpy(data->mailbox, myMailbox);
if (random_target_LOC == NOT_RANDOM) {
if (simulator == ARANTES) {
data->target_LOC = value_target_LOC_stationary;
data->rangeReputationPrimaryToRequest = 0.1;
}
else {
data->target_LOC = value_target_LOC_stationary;
data->rangeReputationPrimaryToRequest = 0.90;
}
}
else {
if (simulator == ARANTES) {
data->target_LOC = (double)(rand() % 51) / 100.0;
data->rangeReputationPrimaryToRequest = 0.1;
}
else {
data->target_LOC = (50.0 + ((double)(rand() % 51))) / 100.0;
data->rangeReputationPrimaryToRequest = 0.1;
}
}
data->start_time = MSG_get_clock();
task = MSG_task_create (task_name, task_compute_duration, task_message_size, data);
MSG_task_send(task, mailbox);
}
开发者ID:marjorieB,项目名称:ByzantineFaults,代码行数:36,代码来源:client.c
注:本文中的MSG_task_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论