33 * Copyright (c) 2013-2023 The University of Tennessee and The University
44 * of Tennessee Research Foundation. All rights
55 * reserved.
6+ * Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
67 */
78
89#include "parsec/parsec_config.h"
@@ -107,7 +108,7 @@ int parsec_select_best_device( parsec_task_t* this_task ) {
107108
108109 /* Run the evaluates for the incarnation types to determine if they can
109110 * execute this task */
110- for (chore_id = 0 ; PARSEC_DEV_NONE != tc -> incarnations [chore_id ].type ; chore_id ++ ) {
111+ for (chore_id = 0 ; PARSEC_DEV_NONE != ( tc -> incarnations [chore_id ].type & PARSEC_DEV_ANY_TYPE ) ; chore_id ++ ) {
111112 if ( 0 == (this_task -> chore_mask & (1 <<chore_id )) ) continue ;
112113 if ( NULL == tc -> incarnations [chore_id ].hook ) continue ; /* dyld hook not found during initialization */
113114
@@ -116,15 +117,15 @@ int parsec_select_best_device( parsec_task_t* this_task ) {
116117 if ( PARSEC_HOOK_RETURN_DONE != rc ) {
117118 if ( PARSEC_HOOK_RETURN_NEXT != rc ) {
118119 PARSEC_DEBUG_VERBOSE (5 , parsec_device_output , "Failed to evaluate %s[%d] chore %d" ,
119- tmp , tc -> incarnations [chore_id ].type ,
120+ tmp , tc -> incarnations [chore_id ].type & PARSEC_DEV_ANY_TYPE ,
120121 chore_id );
121122 }
122123 /* Mark this chore as tested */
123124 this_task -> chore_mask &= ~( 1 <<chore_id );
124125 continue ;
125126 }
126127 }
127- valid_types |= tc -> incarnations [chore_id ].type ; /* the eval accepted the type, but no device specified yet */
128+ valid_types |= ( tc -> incarnations [chore_id ].type & PARSEC_DEV_ANY_TYPE ) ; /* the eval accepted the type, but no device specified yet */
128129 /* Evaluate may have picked a device, abide by it */
129130 if ( NULL != this_task -> selected_device ) {
130131 assert ( this_task -> selected_device -> type & valid_types );
@@ -140,7 +141,7 @@ int parsec_select_best_device( parsec_task_t* this_task ) {
140141 if (PARSEC_DEV_CPU == valid_types ) { /* shortcut for CPU only tasks */
141142 this_task -> selected_device = dev = parsec_mca_device_get (0 );
142143 this_task -> load = 0 ;
143- for (chore_id = 0 ; tc -> incarnations [chore_id ].type != PARSEC_DEV_CPU ; chore_id ++ );
144+ for (chore_id = 0 ; !( tc -> incarnations [chore_id ].type & PARSEC_DEV_CPU ) ; chore_id ++ );
144145 this_task -> selected_chore = chore_id ;
145146 PARSEC_DEBUG_VERBOSE (80 , parsec_device_output , "%s: Task %s cpu-only task set selected_device %d:%s" ,
146147 __func__ , tmp , dev -> device_index , dev -> name );
@@ -226,7 +227,7 @@ int parsec_select_best_device( parsec_task_t* this_task ) {
226227 /* Skip the device if no incarnations for its type */
227228 if (!(dev -> type & valid_types )) continue ;
228229 /* Skip recursive devices: time estimates are computed on the associated CPU device */
229- if (dev -> type == PARSEC_DEV_RECURSIVE ) continue ;
230+ if (dev -> type & PARSEC_DEV_RECURSIVE ) continue ;
230231
231232 eta = dev -> device_load + time_estimate (this_task , dev );
232233 if ( best_eta > eta ) {
@@ -244,14 +245,14 @@ int parsec_select_best_device( parsec_task_t* this_task ) {
244245 goto no_valid_device ;
245246
246247 this_task -> selected_device = parsec_mca_device_get (best_index );
247- assert ( this_task -> selected_device -> type != PARSEC_DEV_RECURSIVE );
248+ assert ( !( this_task -> selected_device -> type & PARSEC_DEV_RECURSIVE ) );
248249 }
249250
250251device_selected :
251252 dev = this_task -> selected_device ;
252253 assert ( NULL != dev );
253254 assert ( tp -> devices_index_mask & (1 << dev -> device_index ) );
254- for (chore_id = 0 ; tc -> incarnations [chore_id ].type != dev -> type ; chore_id ++ )
255+ for (chore_id = 0 ; !( tc -> incarnations [chore_id ].type & dev -> type ) ; chore_id ++ )
255256 assert (PARSEC_DEV_NONE != tc -> incarnations [chore_id ].type /* we have selected this device, so there *must* be an incarnation that matches */ );
256257 this_task -> selected_chore = chore_id ;
257258 this_task -> load = time_estimate (this_task , dev );
@@ -748,8 +749,8 @@ int parsec_mca_device_registration_complete(parsec_context_t* context)
748749 for ( uint32_t i = 0 ; i < parsec_nb_devices ; i ++ ) {
749750 parsec_device_module_t * device = parsec_devices [i ];
750751 if ( NULL == device ) continue ;
751- if ( PARSEC_DEV_RECURSIVE == device -> type ) continue ;
752- if ( PARSEC_DEV_CPU == device -> type ) {
752+ if ( PARSEC_DEV_RECURSIVE & device -> type ) continue ;
753+ if ( PARSEC_DEV_CPU & device -> type ) {
753754 c = 0 ;
754755 for (int p = 0 ; p < context -> nb_vp ; p ++ )
755756 c += context -> virtual_processes [p ]-> nb_cores ;
@@ -768,7 +769,7 @@ int parsec_mca_device_registration_complete(parsec_context_t* context)
768769 for ( uint32_t i = 0 ; i < parsec_nb_devices ; i ++ ) {
769770 parsec_device_module_t * device = parsec_devices [i ];
770771 if ( NULL == device ) continue ;
771- if ( PARSEC_DEV_RECURSIVE == device -> type ) continue ;
772+ if ( PARSEC_DEV_RECURSIVE & device -> type ) continue ;
772773 device -> time_estimate_default = total_gflops_fp64 /(double )device -> gflops_fp64 ;
773774 parsec_debug_verbose (6 , parsec_device_output , " Dev[%d] default-time-estimate %-4" PRId64 " <- double %-8" PRId64 " single %-8" PRId64 " tensor %-8" PRId64 " half %-8" PRId64 " %s" ,
774775 i , device -> time_estimate_default , device -> gflops_fp64 , device -> gflops_fp32 , device -> gflops_tf32 , device -> gflops_fp16 , device -> gflops_guess ? "GUESSED" : "" );
@@ -933,7 +934,7 @@ device_taskpool_register_static(parsec_device_module_t* device, parsec_taskpool_
933934 continue ;
934935 __parsec_chore_t * chores = (__parsec_chore_t * )tc -> incarnations ;
935936 for ( j = 0 ; NULL != chores [j ].hook ; j ++ ) {
936- if ( chores [j ].type != device -> type )
937+ if ( !( chores [j ].type & device -> type ) )
937938 continue ;
938939 if ( NULL != chores [j ].dyld_fn ) {
939940 continue ; /* the function has been set for another device of the same type */
0 commit comments