Changeset 295 for soft/giet_vm/sort/main.c
- Timestamp:
- Mar 26, 2014, 6:44:44 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sort/main.c
r292 r295 1 1 /////////////////////////////////////////////////////////////////////////////// 2 // File : 3 // 4 // main.c 5 // 6 // Date : 7 // 8 // November 2013 9 // 10 // Author : 11 // 12 // Cesar Fuguet Tortolero <cesar.fuguet-tortolero@lip6.fr> 2 // File : main.c 3 // Date : November 2013 4 // Author : Cesar Fuguet Tortolero <cesar.fuguet-tortolero@lip6.fr> 13 5 // 14 6 // Description : … … 38 30 #include "barrier.h" 39 31 40 #define ARRAY_LENGTH 204832 #define ARRAY_LENGTH 512 41 33 #define IPT (ARRAY_LENGTH / *nb_thread) // ITEMS PER THREAD 42 34 … … 47 39 #define VERBOSE 1 48 40 49 /////////////////////////////////////////////////////////////////////// 41 //////////////////////////////////////////////////////////////////////////////// 50 42 // Define printf according to verbosity option and number of available 51 43 // TTY 52 44 53 45 #if (VERBOSE == 1) 54 # define printf(...) giet_tty_printf(__VA_ARGS__) 55 # define puts(...) giet_tty_puts(__VA_ARGS__) 46 # define printf(...) giet_shr_printf(__VA_ARGS__) 56 47 #else // VERBOSE == 0 57 48 # define printf(...) 58 # define puts(...)59 49 #endif 60 50 61 #define task0_printf(...) if(thread_id == 0) giet_ tty_printf(__VA_ARGS__)51 #define task0_printf(...) if(thread_id == 0) giet_shr_printf(__VA_ARGS__) 62 52 63 53 #define exit giet_exit … … 89 79 giet_barrier_t barrier[8]; 90 80 81 ////////////////////////////////////////// 91 82 __attribute__ ((constructor)) void sort() 92 83 { … … 100 91 unsigned int time_end; 101 92 102 if( giet_vobj_get_vbase( "sort" , 103 "nb_thread", 104 VOBJ_TYPE_CONST, 105 (unsigned int*)&nb_thread ) ) 106 { 107 printf( "\n[ERROR] in sort task :\n"); 108 printf( " undefined <nb_thread> constant: %d\n", nb_thread); 109 exit(); 110 } 93 giet_vobj_get_vbase( "sort" , 94 "nb_thread", 95 (unsigned int*)&nb_thread ); 111 96 112 task0_printf(" [Thread 0 ] Starting sort application with %d threads "97 task0_printf("\n[ Thread 0 ] Starting sort application with %d threads " 113 98 "at cycle %d\n", *nb_thread, time_start); 114 99 … … 141 126 // Parallel sort of array elements 142 127 143 printf("[ Thread %d ] Stage 0: ProcessorSorting...\n\r", thread_id);128 printf("[ Thread %d ] Stage 0: Sorting...\n\r", thread_id); 144 129 145 130 bubbleSort(array0, IPT, IPT * thread_id); … … 154 139 if((thread_id % (2 << i)) != 0) 155 140 { 156 printf("[ Thread %d ] Quit s\n\r", thread_id);157 exit( );158 } 159 160 printf("[ Thread %d ] Stage %d: S tarting...\n\r", thread_id, i+1);141 printf("[ Thread %d ] Quit\n\r", thread_id ); 142 exit("Completed"); 143 } 144 145 printf("[ Thread %d ] Stage %d: Sorting...\n\r", thread_id, i+1); 161 146 162 147 if((i % 2) == 0) … … 203 188 204 189 time_end = giet_proctime(); 190 205 191 printf("[ Thread 0 ] Finishing sort application at cycle %d\n" 206 192 "[ Thread 0 ] Time elapsed = %d\n", … … 209 195 if (success) 210 196 { 211 212 printf("[ Thread 0 ] Success!!\n\r"); 197 exit("!!! Success !!!"); 213 198 } 214 199 else 215 200 { 216 printf("[ Thread 0 ] Failure!! Incorrect element: %d\n\r", failure_index); 217 218 201 printf("[ Thread 0 ] Failure!! Incorrect element: %d\n\r", 202 failure_index); 219 203 for(i=0; i<ARRAY_LENGTH; i++) 220 204 { 221 205 printf("array[%d] = %d\n", i, dst_array[i]); 222 206 } 223 }224 }225 226 exit( );207 exit("!!! Failure !!!"); 208 } 209 } 210 exit("Completed"); 227 211 } 228 212 229 void bubbleSort( 230 int *array,231 unsigned int length,232 unsigned int init_pos)213 //////////////////////////////////// 214 void bubbleSort( int * array, 215 unsigned int length, 216 unsigned int init_pos ) 233 217 { 234 218 int i; … … 250 234 } 251 235 236 ///////////// 252 237 void merge( 253 238 int * array,
Note: See TracChangeset
for help on using the changeset viewer.