Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
067cd730bb3a17df40a1490acb72ad4f275f0d6b
[simgrid.git] / examples / msg / trace / test_trace_integration.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "msg/msg.h"
4 #include "xbt/log.h"
5 #include "xbt/asserts.h"
6
7 XBT_LOG_NEW_DEFAULT_CATEGORY(test_trace_integration,
8                              "Messages specific for this msg example");
9
10 int test_trace(int argc, char *argv[]);
11
12 /** test the trace integration cpu model */
13 int test_trace(int argc, char *argv[])
14 {
15         m_task_t task;
16         double task_comp_size = 2800;
17         double task_prio = 1.0;
18
19         if (argc != 3) {
20                 printf("Wrong number of arguments!\nUsage:\n\t1) task computational size in FLOPS\n\t2 task priority\n");
21             exit(1);
22         }
23
24         task_comp_size = atof(argv[1]);
25         task_prio = atof(argv[2]);
26
27         INFO0("Testing the trace integration cpu model: CpuTI");
28         INFO1("Task size: %lf", task_comp_size);
29         INFO1("Task prio: %lf", task_prio);
30
31         /* Create and execute a single task. */
32         task = MSG_task_create("proc 0", task_comp_size, 0, NULL);
33         MSG_task_set_priority(task, task_prio);
34         MSG_task_execute(task);
35
36         INFO0("Test finished");
37
38
39         return 0;
40 }
41
42 /** Main function */
43 int main(int argc, char *argv[])
44 {
45   MSG_error_t res = MSG_OK;
46
47   /* Verify if the platform xml file was passed by command line. */
48   MSG_global_init(&argc, argv);
49   if (argc < 2) {
50     printf("Usage: %s test_trace_integration_model.xml\n", argv[0]);
51     exit(1);
52   }
53
54   /* Register SimGrid process function. */
55   MSG_function_register("test_trace", test_trace);
56   /* Use the same file for platform and deployment. */
57   MSG_create_environment(argv[1]);
58   MSG_launch_application(argv[1]);
59   /* Run the example. */
60   res = MSG_main();
61
62   MSG_clean();
63
64   if (res == MSG_OK)
65     return 0;
66   else
67     return 1;
68 }