Changeset 292
- Timestamp:
- Feb 14, 2014, 2:38:53 PM (11 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sort/main.c
r271 r292 34 34 35 35 #include "stdio.h" 36 #include "mapping_info.h" 36 37 #include "hard_config.h" 37 38 #include "barrier.h" 38 39 39 ////////////////////////////////////////////////////////////////////////// 40 // The NTHREADS constant must be modified depending on the desired number of 41 // threads 42 43 #define NTHREADS 8 44 #define ARRAY_LENGTH (NTHREADS * 128) 45 #define IPT (ARRAY_LENGTH / NTHREADS) // ITEMS PER THREAD 40 #define ARRAY_LENGTH 2048 41 #define IPT (ARRAY_LENGTH / *nb_thread) // ITEMS PER THREAD 46 42 47 43 //////////////////////////////////////////////////////////////////////////////// … … 72 68 int array1[ARRAY_LENGTH]; 73 69 74 volatileint init_ok = 0;70 int init_ok = 0; 75 71 76 72 void bubbleSort( … … 89 85 /////////////////////////////////////////////////// 90 86 // This application support at most 256 processors 91 // Number of barriers = log2( NTHREADS)87 // Number of barriers = log2(nb_thread) 92 88 93 89 giet_barrier_t barrier[8]; … … 96 92 { 97 93 int thread_id = giet_thread_id(); 98 94 unsigned int* nb_thread; 99 95 int * src_array; 100 96 int * dst_array; 101 97 int i; 102 103 printf("[ Thread %d ] Initializing vector and barriers...\n\r", thread_id); 98 99 unsigned int time_start = giet_proctime(); 100 unsigned int time_end; 101 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 } 111 112 task0_printf("[Thread 0 ] Starting sort application with %d threads " 113 "at cycle %d\n", *nb_thread, time_start); 104 114 105 115 /////////////////////////// 106 116 // Barriers Initialization 107 117 108 for (i = 0; i < __builtin_ctz(NTHREADS); i++) 109 { 110 barrier_init(&barrier[i], NTHREADS >> i); 118 if (thread_id == 0) 119 { 120 for (i = 0; i < __builtin_ctz(*nb_thread); i++) 121 { 122 barrier_init(&barrier[i], *nb_thread >> i); 123 } 124 125 init_ok = 1; 126 } 127 else 128 { 129 while(!init_ok); 111 130 } 112 131 … … 128 147 printf("[ Thread %d ] Finishing Stage 0\n\r", thread_id); 129 148 130 for (i = 0; i < __builtin_ctz( NTHREADS); i++)149 for (i = 0; i < __builtin_ctz(*nb_thread); i++) 131 150 { 132 151 asm volatile ("sync"); … … 183 202 } 184 203 204 time_end = giet_proctime(); 205 printf("[ Thread 0 ] Finishing sort application at cycle %d\n" 206 "[ Thread 0 ] Time elapsed = %d\n", 207 time_end, (time_end - time_start) ); 208 185 209 if (success) 186 210 { 211 187 212 printf("[ Thread 0 ] Success!!\n\r"); 188 213 }
Note: See TracChangeset
for help on using the changeset viewer.