@@ -48,7 +48,6 @@ static void
4848l_init_kernel_invocation_wrapper (acl_kernel_invocation_wrapper_t *wrapper,
4949 unsigned i);
5050static void l_forcibly_release_allocations (cl_context context);
51- static cl_device_id l_find_device_by_name (const std::string &name);
5251static cl_int l_update_program_library_root (cl_context context,
5352 const char *new_root);
5453static cl_int l_update_compile_command (cl_context context, const char *new_cmd);
@@ -606,12 +605,11 @@ static cl_int l_load_properties(cl_context context,
606605 }
607606 }
608607
609- // Environment variable can specify we always an offline device.
610- if (!acl_platform.offline_device .empty ()) {
611- if (!l_find_device_by_name (acl_platform.offline_device ))
612- ERR_RET (CL_INVALID_VALUE, context,
613- " Invalid offline device specified by environment variable "
614- " CL_CONTEXT_OFFLINE_DEVICE_INTELFPGA" );
608+ // Check if environment variable specified offline device is valid
609+ if (acl_platform.has_offline_device < 0 ) {
610+ ERR_RET (CL_INVALID_VALUE, context,
611+ " Invalid offline device specified by environment variable "
612+ " CL_CONTEXT_OFFLINE_DEVICE_INTELFPGA" );
615613 }
616614
617615 // Get default for program_library_root.
@@ -817,17 +815,6 @@ static cl_int l_load_properties(cl_context context,
817815 return CL_SUCCESS;
818816}
819817
820- static cl_device_id l_find_device_by_name (const std::string &name) {
821- acl_assert_locked ();
822-
823- for (unsigned i = 0 ; i < acl_platform.num_devices ; ++i) {
824- if (name == acl_platform.device [i].def .autodiscovery_def .name ) {
825- return &(acl_platform.device [i]);
826- }
827- }
828- return 0 ;
829- }
830-
831818// Initialize the given context.
832819// Yes, this is like a "placement new".
833820//
@@ -883,8 +870,6 @@ static cl_int l_init_context_with_devices(cl_context context,
883870 int num_present = 0 ;
884871 int num_absent = 0 ;
885872 for (cl_uint i = 0 ; i < num_devices; i++) {
886- int usable = devices[i]->present ;
887-
888873 // Can't mix both (actually) present and absent devices because there
889874 // is no consistent way to place device global memory.
890875 if (devices[i]->present ) {
@@ -900,10 +885,7 @@ static cl_int l_init_context_with_devices(cl_context context,
900885 " Can't create a context with both offline and online devices" );
901886 }
902887
903- usable = usable || acl_platform.offline_device ==
904- devices[i]->def .autodiscovery_def .name ;
905-
906- if (!usable)
888+ if (!devices[i]->present && !devices[i]->offline )
907889 ERR_RET (CL_DEVICE_NOT_AVAILABLE, context, " Device not available" );
908890
909891 // Mark the device(s) as opened
0 commit comments