- Timestamp:
- Jun 14, 2016, 5:23:56 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/src-par/mca_rosenfeld.c
r822 r823 142 142 } 143 143 #endif // FEATURES && !PARMERGE 144 145 146 #if !FEATURES && PARMERGE 147 // ----------------------------------------------------------------------------------------------------------- 148 static bool SetRoot_Parallel_Rosenfeld_Dist(uint32 ** D, uint32 root, uint32 eps, int shift, RegionStats ** F) 149 // ----------------------------------------------------------------------------------------------------------- 150 { 151 assert(root != 0 && eps != 0); 152 153 MCA_VERBOSE3(printf("F(%d) += F(%d)\n", eps, root)); 154 155 int mask = (1 << shift) - 1; 156 157 uint32 r1 = root >> shift; 158 uint32 r0 = root & mask; 159 160 uint32 e1 = eps >> shift; 161 uint32 e0 = eps & mask; 162 163 // Locking towards the root (first root, then eps) 164 pthread_spin_lock(&F[r1][r0].lock); 165 pthread_spin_lock(&F[e1][e0].lock); 166 if (D[e1][e0] != eps || D[r1][r0] != root) { 167 // Someone change the root of epsilon or "root", need to find the new root 168 pthread_spin_unlock(&F[e1][e0].lock); 169 pthread_spin_unlock(&F[r1][r0].lock); 170 return false; 171 } 172 173 D[r1][r0] = eps; 174 175 pthread_spin_unlock(&F[e1][e0].lock); 176 pthread_spin_unlock(&F[r1][r0].lock); 177 return true; 178 } 179 #endif // !FEATURES && PARMERGE 144 180 145 181 … … 585 621 586 622 587 #if FAST && FEATURES && PARMERGE && !ARSP623 #if FAST && PARMERGE && !ARSP // Valid for FEATURES and !FEATURES 588 624 // --------------------------------------------------------------------------------------------------------------------------- 589 static void vuse2_Parallel_ Features_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha, RegionStats ** F)625 static void vuse2_Parallel_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 590 626 // --------------------------------------------------------------------------------------------------------------------------- 591 627 { … … 610 646 // qui a fait un test 611 647 if (rd < rl) { 612 ok = SetRoot_Parallel_Features_Rosenfeld_Dist(D, rl, rd, alpha, F); 648 // Features or No Features depending on config 649 ok = SetRoot_Parallel_FNF(D, rl, rd, alpha, F); 613 650 } 614 651 else { 615 ok = SetRoot_Parallel_F eatures_Rosenfeld_Dist(D, rd, rl, alpha, F);652 ok = SetRoot_Parallel_FNF(D, rd, rl, alpha, F); 616 653 } 617 654 } while (!ok); 618 655 } 619 656 620 // FAST && FEATURES &&PARMERGE && !ARSP657 // FAST && PARMERGE && !ARSP 621 658 622 659 // ----------------------------------------------------------------------------------------------------------------------------------------- 623 static void vuse3_Parallel_ Features_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha, RegionStats ** F)660 static void vuse3_Parallel_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 624 661 // ----------------------------------------------------------------------------------------------------------------------------------------- 625 662 { … … 649 686 ok3 = true; 650 687 if (r1 > eps) { 651 ok1 = SetRoot_Parallel_F eatures_Rosenfeld_Dist(D, r1, eps, alpha, F);688 ok1 = SetRoot_Parallel_FNF(D, r1, eps, alpha, F); 652 689 } 653 690 if (r2 > eps && r2 != r1) { 654 ok2 = SetRoot_Parallel_F eatures_Rosenfeld_Dist(D, r2, eps, alpha, F);691 ok2 = SetRoot_Parallel_FNF(D, r2, eps, alpha, F); 655 692 } 656 693 if (r3 > eps && r3 != r2 && r3 != r1) { 657 ok3 = SetRoot_Parallel_F eatures_Rosenfeld_Dist(D, r3, eps, alpha, F);694 ok3 = SetRoot_Parallel_FNF(D, r3, eps, alpha, F); 658 695 } 659 696 } while (!(ok1 && ok2 && ok3)); 660 697 } 661 #endif // FAST && FEATURES &&PARMERGE && !ARSP698 #endif // FAST && PARMERGE && !ARSP 662 699 663 700 … … 1381 1418 uint32 e0 = mca->e0; 1382 1419 uint32 e1 = mca->e1; 1420 uint32 ne_prev = mca->ne_prev; 1383 1421 uint32 ne = e0 - 1; 1384 1422 uint32 nr = 0; … … 1390 1428 RegionStats * stats = mca->stats; 1391 1429 1392 // reset sous optimal (pour le moment = voir region32)1393 if (mca->p == 0) { 1394 set_ui32vector_j(T, e0 - 1, e1); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot1430 CLOCK_THREAD_START_STEP(mca->p, 0); 1431 1432 set_ui32vector_j(T, e0, ne_prev); 1395 1433 #if FEATURES 1396 zero_RegionStatsVector(stats, e0 - 1, e1);1434 zero_RegionStatsVector(stats, e0, ne_prev); 1397 1435 #endif 1398 }1399 else {1400 set_ui32vector_j(T, e0, e1);1401 #if FEATURES1402 zero_RegionStatsVector(stats, e0, e1);1403 #endif1404 }1405 1436 1406 1437 if (mca->p == 0) { … … 1411 1442 // -- Etiquetage d'une bande -- // 1412 1443 // ---------------------------- // 1413 1414 CLOCK_THREAD_START_STEP(mca->p, 0);1415 1444 1416 1445 ne = line0Labeling_Rosenfeld(X, i0, width, E, T, ne); … … 1644 1673 1645 1674 CLOCK_THREAD_START(mca->p); 1646 CLOCK_THREAD_COMPUTE_START(mca->p); 1647 1648 MCA_Scatter_ImageX(mca); 1649 pthread_barrier_wait(&main_barrier); 1650 1651 MCA_Label_Rosenfeld_PAR1(mca); 1652 pthread_barrier_wait(&main_barrier); 1653 1675 1676 int num_runs = mca->nr; 1677 1678 // We always perform one more run than the num_runs 1679 // value, so as to know "ne", i.e. the number of 1680 // elements to reset in the T and F tables (labels and stats) 1681 // After this first extra run, clock times are not accumulated 1682 // and thus are lost. 1683 // Note: the CLOCK_THREAD_START will still include this first run, 1684 // and in case of multiple runs, only averaged times should be 1685 // considered. 1686 for (int run = 0; run < num_runs + 1; run++) { 1687 1688 CLOCK_THREAD_COMPUTE_START(mca->p); 1689 1690 MCA_Scatter_ImageX(mca); 1691 pthread_barrier_wait(&main_barrier); 1692 1693 MCA_Label_Rosenfeld_PAR1(mca); 1694 pthread_barrier_wait(&main_barrier); 1695 1654 1696 #if PARMERGE 1655 MCA_Label_Rosenfeld_PAR2(mca);1697 MCA_Label_Rosenfeld_PAR2(mca); 1656 1698 #else 1657 MCA_Label_Rosenfeld_PYR2(mca);1699 MCA_Label_Rosenfeld_PYR2(mca); 1658 1700 #endif 1659 pthread_barrier_wait(&main_barrier); 1660 1661 MCA_Label_Rosenfeld_PAR3(mca); 1662 pthread_barrier_wait(&main_barrier); 1663 1664 MCA_Gather_ImageL(mca); 1665 pthread_barrier_wait(&main_barrier); 1666 1667 CLOCK_THREAD_COMPUTE_END(mca->p); 1701 pthread_barrier_wait(&main_barrier); 1702 1703 MCA_Label_Rosenfeld_PAR3(mca); 1704 pthread_barrier_wait(&main_barrier); 1705 1706 MCA_Gather_ImageL(mca); 1707 pthread_barrier_wait(&main_barrier); 1708 1709 CLOCK_THREAD_COMPUTE_END(mca->p); 1710 1711 if (run == 0) { 1712 // Mise à jour du ne_prev par chaque thread 1713 mca->ne_prev = mca->ne; 1714 mca->ne = 0; 1715 } 1716 else { 1717 // Accumulation du temps COMPUTE et de toutes les STEP 1718 if (mca->p == 0) { 1719 CLOCK_ACCUMULATE; 1720 } 1721 assert(mca->ne == mca->ne_prev); 1722 // Reinitialisation de "ne" s'il ne s'agit pas du dernier run 1723 if (run != num_runs) { 1724 mca->ne = 0; 1725 } 1726 } 1727 pthread_barrier_wait(&main_barrier); 1728 } 1729 1668 1730 1669 1731 #if FEATURES
Note: See TracChangeset
for help on using the changeset viewer.