1 //------------------------------------------------------------------------------ 2 // GB_parition.h: definitions for partitioning an index range 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 #ifndef GB_PARTITION_H 11 #define GB_PARTITION_H 12 13 // GB_PART and GB_PARTITION: divide the index range 0:n-1 equally 14 // for nthreads. GB_PART(tid,n,nthreads) is the first index for thread tid. 15 #define GB_PART(tid,n,nthreads) \ 16 (((tid) * ((double) (n))) / ((double) (nthreads))) 17 18 // thread tid will operate on the range k1:(k2-1) 19 #define GB_PARTITION(k1,k2,n,tid,nthreads) \ 20 k1 = ((tid) == 0 ) ? 0 : GB_PART ((tid), n, nthreads) ; \ 21 k2 = ((tid) == (nthreads)-1) ? (n) : GB_PART ((tid)+1,n, nthreads) 22 23 #endif 24 25