1 //------------------------------------------------------------------------------ 2 // GB_unjumble_template: unjumble the vectors of a matrix 3 //------------------------------------------------------------------------------ 4 5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 6 // SPDX-License-Identifier: Apache-2.0 7 8 //------------------------------------------------------------------------------ 9 10 { 11 int tid ; 12 #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1) 13 for (tid = 0 ; tid < ntasks ; tid++) 14 { 15 16 //---------------------------------------------------------------------- 17 // get the task description 18 //---------------------------------------------------------------------- 19 20 int64_t kfirst = A_slice [tid] ; 21 int64_t klast = A_slice [tid+1] ; 22 23 //---------------------------------------------------------------------- 24 // sort vectors kfirst to klast 25 //---------------------------------------------------------------------- 26 27 for (int64_t k = kfirst ; k < klast ; k++) 28 { 29 30 //------------------------------------------------------------------ 31 // check if the vector needs sorting 32 //------------------------------------------------------------------ 33 34 bool jumbled = false ; 35 int64_t pA_start = Ap [k] ; 36 int64_t pA_end = Ap [k+1] ; 37 int64_t ilast = -1 ; 38 for (int64_t pA = pA_start ; pA < pA_end ; pA++) 39 { 40 int64_t i = Ai [pA] ; 41 if (i < ilast) 42 { 43 jumbled = true ; 44 break ; 45 } 46 ilast = i ; 47 } 48 49 //------------------------------------------------------------------ 50 // sort the vector 51 //------------------------------------------------------------------ 52 53 if (jumbled) 54 { 55 int64_t aknz = pA_end - pA_start ; 56 GB_QSORT ; 57 } 58 } 59 } 60 } 61 62 #undef GB_QSORT 63