Changeset 271 for soft/giet_vm/sort/main.c
- Timestamp:
- Jan 17, 2014, 11:49:27 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sort/main.c
r269 r271 38 38 39 39 ////////////////////////////////////////////////////////////////////////// 40 // The N PROCS constant must be modified depending on the desired number of40 // The NTHREADS constant must be modified depending on the desired number of 41 41 // threads 42 42 43 #define N PROCS 444 #define ARRAY_LENGTH (N PROCS * 128)45 #define IP P (ARRAY_LENGTH / NPROCS) // ITEMS PER PROCESSOR43 #define NTHREADS 8 44 #define ARRAY_LENGTH (NTHREADS * 128) 45 #define IPT (ARRAY_LENGTH / NTHREADS) // ITEMS PER THREAD 46 46 47 47 //////////////////////////////////////////////////////////////////////////////// … … 89 89 /////////////////////////////////////////////////// 90 90 // This application support at most 256 processors 91 // Number of barriers = log2(N PROCS)91 // Number of barriers = log2(NTHREADS) 92 92 93 93 giet_barrier_t barrier[8]; … … 101 101 int i; 102 102 103 task0_printf("[ Thread 0 ] Starting SORT application\n");103 printf("[ Thread %d ] Initializing vector and barriers...\n\r", thread_id); 104 104 105 105 /////////////////////////// 106 106 // Barriers Initialization 107 107 108 for (i = 0; i < __builtin_ctz(N PROCS); i++)109 { 110 barrier_init(&barrier[i], N PROCS >> i);108 for (i = 0; i < __builtin_ctz(NTHREADS); i++) 109 { 110 barrier_init(&barrier[i], NTHREADS >> i); 111 111 } 112 112 … … 114 114 // Array Initialization 115 115 116 for (i = IP P * thread_id; i < IPP* (thread_id + 1); i++)116 for (i = IPT * thread_id; i < IPT * (thread_id + 1); i++) 117 117 { 118 118 array0[i] = rand(); … … 124 124 printf("[ Thread %d ] Stage 0: Processor Sorting...\n\r", thread_id); 125 125 126 bubbleSort(array0, IP P, IPP* thread_id);126 bubbleSort(array0, IPT, IPT * thread_id); 127 127 128 128 printf("[ Thread %d ] Finishing Stage 0\n\r", thread_id); 129 129 130 for (i = 0; i < __builtin_ctz(N PROCS); i++)130 for (i = 0; i < __builtin_ctz(NTHREADS); i++) 131 131 { 132 132 asm volatile ("sync"); … … 153 153 154 154 merge(src_array, dst_array 155 , IP P<< i156 , IP P* thread_id157 , IP P* (thread_id + (1 << i))158 , IP P* thread_id155 , IPT << i 156 , IPT * thread_id 157 , IPT * (thread_id + (1 << i)) 158 , IPT * thread_id 159 159 ); 160 160
Note: See TracChangeset
for help on using the changeset viewer.