vector<DeviceInfo>& Device::available_devices() { thread_scoped_lock lock(device_mutex); if(need_devices_update) { devices.clear(); #ifdef WITH_OPENCL if(device_opencl_init()) { device_opencl_info(devices); } #endif #ifdef WITH_CUDA if(device_cuda_init()) { device_cuda_info(devices); } #endif device_cpu_info(devices); #ifdef WITH_NETWORK device_network_info(devices); #endif need_devices_update = false; } return devices; }
vector<DeviceInfo>& Device::available_devices() { static vector<DeviceInfo> devices; static bool devices_init = false; if(!devices_init) { #ifdef WITH_CUDA if(device_cuda_init()) device_cuda_info(devices); #endif #ifdef WITH_OPENCL if(device_opencl_init()) device_opencl_info(devices); #endif #ifdef WITH_MULTI device_multi_info(devices); #endif device_cpu_info(devices); #ifdef WITH_NETWORK device_network_info(devices); #endif devices_init = true; } return devices; }
vector<DeviceType>& Device::available_types() { static vector<DeviceType> types; static bool types_init = false; if(!types_init) { types.push_back(DEVICE_CPU); #ifdef WITH_CUDA if(device_cuda_init()) types.push_back(DEVICE_CUDA); #endif #ifdef WITH_OPENCL if(device_opencl_init()) types.push_back(DEVICE_OPENCL); #endif #ifdef WITH_NETWORK types.push_back(DEVICE_NETWORK); #endif #ifdef WITH_MULTI types.push_back(DEVICE_MULTI); #endif types_init = true; } return types; }
vector<DeviceInfo>& Device::available_devices() { if(need_devices_update) { devices.clear(); #ifdef WITH_CUDA if(device_cuda_init()) device_cuda_info(devices); #endif #ifdef WITH_OPENCL if(device_opencl_init()) device_opencl_info(devices); #endif #ifdef WITH_MULTI device_multi_info(devices); #endif device_cpu_info(devices); #ifdef WITH_NETWORK device_network_info(devices); #endif need_devices_update = false; } return devices; }
vector<DeviceType>& Device::available_types() { if(need_types_update) { types.clear(); types.push_back(DEVICE_CPU); #ifdef WITH_CUDA if(device_cuda_init()) types.push_back(DEVICE_CUDA); #endif #ifdef WITH_OPENCL if(device_opencl_init()) types.push_back(DEVICE_OPENCL); #endif #ifdef WITH_NETWORK types.push_back(DEVICE_NETWORK); #endif #ifdef WITH_MULTI types.push_back(DEVICE_MULTI); #endif need_types_update = false; } return types; }
string Device::device_capabilities() { string capabilities = "CPU device capabilities: "; capabilities += device_cpu_capabilities() + "\n"; #ifdef WITH_CUDA if(device_cuda_init()) { capabilities += "\nCUDA device capabilities:\n"; capabilities += device_cuda_capabilities(); } #endif #ifdef WITH_OPENCL if(device_opencl_init()) { capabilities += "\nOpenCL device capabilities:\n"; capabilities += device_opencl_capabilities(); } #endif return capabilities; }
Device *Device::create(DeviceInfo& info, Stats &stats, bool background) { Device *device; switch(info.type) { case DEVICE_CPU: device = device_cpu_create(info, stats, background); break; #ifdef WITH_CUDA case DEVICE_CUDA: if(device_cuda_init()) device = device_cuda_create(info, stats, background); else device = NULL; break; #endif #ifdef WITH_MULTI case DEVICE_MULTI: device = device_multi_create(info, stats, background); break; #endif #ifdef WITH_NETWORK case DEVICE_NETWORK: device = device_network_create(info, stats, "127.0.0.1"); break; #endif #ifdef WITH_OPENCL case DEVICE_OPENCL: if(device_opencl_init()) device = device_opencl_create(info, stats, background); else device = NULL; break; #endif default: return NULL; } return device; }
string Device::device_capabilities() { string capabilities = "CPU device capabilities: "; capabilities += device_cpu_capabilities() + "\n"; #ifdef WITH_CUDA if(device_cuda_init()) { capabilities += "\nCUDA device capabilities:\n"; capabilities += device_cuda_capabilities(); } #endif #ifdef WITH_OPENCL /* TODO(sergey): Needs proper usable implementation. */ /* if(device_opencl_init()) { capabilities += "\nOpenCL device capabilities:\n"; capabilities += device_opencl_capabilities(); } */ #endif return capabilities; }