Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/device_opencl.cpp
| Show All 23 Lines | |||||
| #include "util/util_logging.h" | #include "util/util_logging.h" | ||||
| #include "util/util_set.h" | #include "util/util_set.h" | ||||
| #include "util/util_string.h" | #include "util/util_string.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| Device *device_opencl_create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background) | Device *device_opencl_create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background) | ||||
| { | { | ||||
| vector<OpenCLPlatformDevice> usable_devices; | |||||
| OpenCLInfo::get_usable_devices(&usable_devices); | |||||
| assert(info.num < usable_devices.size()); | |||||
| const OpenCLPlatformDevice& platform_device = usable_devices[info.num]; | |||||
| const string& platform_name = platform_device.platform_name; | |||||
| const cl_device_type device_type = platform_device.device_type; | |||||
| if(OpenCLInfo::kernel_use_split(platform_name, device_type)) { | |||||
| VLOG(1) << "Using split kernel."; | |||||
| return opencl_create_split_device(info, stats, profiler, background); | return opencl_create_split_device(info, stats, profiler, background); | ||||
| } else { | |||||
| VLOG(1) << "Using mega kernel."; | |||||
| return opencl_create_mega_device(info, stats, profiler, background); | |||||
| } | |||||
| } | } | ||||
| bool device_opencl_init() | bool device_opencl_init() | ||||
| { | { | ||||
| static bool initialized = false; | static bool initialized = false; | ||||
| static bool result = false; | static bool result = false; | ||||
| if(initialized) | if(initialized) | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | void device_opencl_info(vector<DeviceInfo>& devices) | ||||
| vector<OpenCLPlatformDevice> usable_devices; | vector<OpenCLPlatformDevice> usable_devices; | ||||
| OpenCLInfo::get_usable_devices(&usable_devices); | OpenCLInfo::get_usable_devices(&usable_devices); | ||||
| /* Devices are numbered consecutively across platforms. */ | /* Devices are numbered consecutively across platforms. */ | ||||
| int num_devices = 0; | int num_devices = 0; | ||||
| set<string> unique_ids; | set<string> unique_ids; | ||||
| foreach(OpenCLPlatformDevice& platform_device, usable_devices) { | foreach(OpenCLPlatformDevice& platform_device, usable_devices) { | ||||
| /* Compute unique ID for persistent user preferences. */ | /* Compute unique ID for persistent user preferences. */ | ||||
| const string& platform_name = platform_device.platform_name; | const string& platform_name = platform_device.platform_name; | ||||
| const cl_device_type device_type = platform_device.device_type; | |||||
| const string& device_name = platform_device.device_name; | const string& device_name = platform_device.device_name; | ||||
| string hardware_id = platform_device.hardware_id; | string hardware_id = platform_device.hardware_id; | ||||
| if(hardware_id == "") { | if(hardware_id == "") { | ||||
| hardware_id = string_printf("ID_%d", num_devices); | hardware_id = string_printf("ID_%d", num_devices); | ||||
| } | } | ||||
| string id = string("OPENCL_") + platform_name + "_" + device_name + "_" + hardware_id; | string id = string("OPENCL_") + platform_name + "_" + device_name + "_" + hardware_id; | ||||
| /* Hardware ID might not be unique, add device number in that case. */ | /* Hardware ID might not be unique, add device number in that case. */ | ||||
| if(unique_ids.find(id) != unique_ids.end()) { | if(unique_ids.find(id) != unique_ids.end()) { | ||||
| id += string_printf("_ID_%d", num_devices); | id += string_printf("_ID_%d", num_devices); | ||||
| } | } | ||||
| unique_ids.insert(id); | unique_ids.insert(id); | ||||
| /* Create DeviceInfo. */ | /* Create DeviceInfo. */ | ||||
| DeviceInfo info; | DeviceInfo info; | ||||
| info.type = DEVICE_OPENCL; | info.type = DEVICE_OPENCL; | ||||
| info.description = string_remove_trademark(string(device_name)); | info.description = string_remove_trademark(string(device_name)); | ||||
| info.num = num_devices; | info.num = num_devices; | ||||
| /* We don't know if it's used for display, but assume it is. */ | /* We don't know if it's used for display, but assume it is. */ | ||||
| info.display_device = true; | info.display_device = true; | ||||
| info.advanced_shading = OpenCLInfo::kernel_use_advanced_shading(platform_name); | info.advanced_shading = OpenCLInfo::kernel_use_advanced_shading(platform_name); | ||||
| info.use_split_kernel = OpenCLInfo::kernel_use_split(platform_name, | info.use_split_kernel = true; | ||||
| device_type); | |||||
| info.has_volume_decoupled = false; | info.has_volume_decoupled = false; | ||||
| info.id = id; | info.id = id; | ||||
| /* Check OpenCL extensions */ | /* Check OpenCL extensions */ | ||||
| info.has_half_images = platform_device.device_extensions.find("cl_khr_fp16") != string::npos; | info.has_half_images = platform_device.device_extensions.find("cl_khr_fp16") != string::npos; | ||||
| devices.push_back(info); | devices.push_back(info); | ||||
| num_devices++; | num_devices++; | ||||
| ▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines | |||||