Logo AND Algorithmique Numérique Distribuée

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