| 1 | divert(-1) | 
|---|
| 2 | define(NEWPROC,) dnl | 
|---|
| 3 |  | 
|---|
| 4 | define(BARRIER, `{ | 
|---|
| 5 |     unsigned int wait_start, wait_end; | 
|---|
| 6 |     unsigned int id = giet_thread_id(); | 
|---|
| 7 |      | 
|---|
| 8 |     CLOCK(wait_start) | 
|---|
| 9 |     sqt_barrier_wait(&($1)); | 
|---|
| 10 |     CLOCK(wait_end) | 
|---|
| 11 |     *gp[id].sync_time += wait_end - wait_start; | 
|---|
| 12 |      | 
|---|
| 13 | }') | 
|---|
| 14 |  | 
|---|
| 15 | define(BARDEC, ` | 
|---|
| 16 | giet_sqt_barrier_t ($1); | 
|---|
| 17 | ') | 
|---|
| 18 |  | 
|---|
| 19 | define(BARINIT, `{ | 
|---|
| 20 |     giet_assert (nclusters_x * nclusters_y * procs_per_cluster == (unsigned int)$2, "Incorrect mesh for sqt_barrier\n"); | 
|---|
| 21 |      | 
|---|
| 22 |     while (heap_inited != $2) { | 
|---|
| 23 |         asm volatile("nop\r\n"); | 
|---|
| 24 |     } | 
|---|
| 25 |     giet_tty_printf("Tas initialisés\n"); | 
|---|
| 26 |         sqt_barrier_init(&($1), nclusters_x, nclusters_y, procs_per_cluster); | 
|---|
| 27 | }') | 
|---|
| 28 |  | 
|---|
| 29 | define(LOCKDEC, `sqt_lock_t ($1);') | 
|---|
| 30 | define(LOCKINIT, `{ | 
|---|
| 31 |     sqt_lock_init(&($1), nclusters_x, nclusters_y, procs_per_cluster); | 
|---|
| 32 | }') | 
|---|
| 33 | define(LOCK, `{ | 
|---|
| 34 |     unsigned int wait_start, wait_end; | 
|---|
| 35 |     unsigned int id = giet_thread_id(); | 
|---|
| 36 |     CLOCK(wait_start) | 
|---|
| 37 |     sqt_lock_acquire(&($1)); | 
|---|
| 38 |     CLOCK(wait_end) | 
|---|
| 39 |     *gp[id].sync_time += wait_end - wait_start; | 
|---|
| 40 | }') | 
|---|
| 41 | define(UNLOCK, `{sqt_lock_release(&($1));}') | 
|---|
| 42 |  | 
|---|
| 43 | define(WAIT_FOR_END, `{ | 
|---|
| 44 |         giet_tty_printf("Wait threads...\n"); | 
|---|
| 45 |         BARRIER(bars->barrier) | 
|---|
| 46 | }') | 
|---|
| 47 |  | 
|---|
| 48 | define(CREATE, `{ | 
|---|
| 49 |     long id_main = 0; | 
|---|
| 50 |         run_threads = 1; | 
|---|
| 51 |    $1(&id_main); | 
|---|
| 52 | }') | 
|---|
| 53 |  | 
|---|
| 54 | define(MAIN_INITENV, `{ | 
|---|
| 55 |     giet_procs_number(&nclusters_x, &nclusters_y, &procs_per_cluster); | 
|---|
| 56 |         heap_init(0, 0); | 
|---|
| 57 |         heap_inited += procs_per_cluster; | 
|---|
| 58 | }') | 
|---|
| 59 | define(MAIN_END, `{exit(0); return 0;}') | 
|---|
| 60 |  | 
|---|
| 61 | define(MAIN_ENV,` | 
|---|
| 62 | #include <user_sqt_lock.h> | 
|---|
| 63 | #include <user_barrier.h> | 
|---|
| 64 | #include <stdio.h> | 
|---|
| 65 | #include <stdlib.h> | 
|---|
| 66 | #include <malloc.h> | 
|---|
| 67 | #include "giet_utils.h" | 
|---|
| 68 |  | 
|---|
| 69 | #define MAX_THREADS 512 | 
|---|
| 70 | /*#include <pthread.h> | 
|---|
| 71 | #include <sys/time.h> | 
|---|
| 72 | #include <sys/fcntl.h> | 
|---|
| 73 | #include <sys/resource.h> | 
|---|
| 74 | #include <unistd.h> | 
|---|
| 75 | #include <stdlib.h> | 
|---|
| 76 | pthread_t PThreadTable[MAX_THREADS]; | 
|---|
| 77 | */ | 
|---|
| 78 | ') | 
|---|
| 79 |  | 
|---|
| 80 | define(ENV, ` ') | 
|---|
| 81 | define(EXTERN_ENV, ` | 
|---|
| 82 |  | 
|---|
| 83 | #include <user_sqt_lock.h> | 
|---|
| 84 | #include <user_barrier.h> | 
|---|
| 85 | #include <stdio.h> | 
|---|
| 86 | #include <malloc.h> | 
|---|
| 87 |  | 
|---|
| 88 | #include "giet_utils.h" | 
|---|
| 89 |  | 
|---|
| 90 | /*#include <pthread.h> | 
|---|
| 91 | #include <sys/time.h> | 
|---|
| 92 | #include <sys/stat.h> | 
|---|
| 93 | #include <sys/resource.h> | 
|---|
| 94 | #include <unistd.h> | 
|---|
| 95 | #include <stdlib.h> | 
|---|
| 96 | #include <stdio.h> | 
|---|
| 97 | extern pthread_t PThreadTable[];*/ | 
|---|
| 98 | ') | 
|---|
| 99 |  | 
|---|
| 100 | define(G_MALLOC, `ocean_malloc($1, $2);') | 
|---|
| 101 |  | 
|---|
| 102 | define(CLOCK, `{ | 
|---|
| 103 |    ($1) = giet_proctime(); | 
|---|
| 104 | }') | 
|---|
| 105 |  | 
|---|
| 106 | define(START_PHASE, `{ | 
|---|
| 107 |     CLOCK(*gp[$1].step_start) | 
|---|
| 108 | }') | 
|---|
| 109 | define(END_PHASE, `{ | 
|---|
| 110 |     unsigned int t; | 
|---|
| 111 |     CLOCK(t) | 
|---|
| 112 |     gp[$1].steps_time[($2)-1] += (double)t - *gp[$1].step_start; | 
|---|
| 113 | }') | 
|---|
| 114 |  | 
|---|
| 115 | divert(0) | 
|---|