Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/device.cpp
| Show All 28 Lines | |||||
| #include "util_types.h" | #include "util_types.h" | ||||
| #include "util_vector.h" | #include "util_vector.h" | ||||
| #include "util_string.h" | #include "util_string.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| bool Device::need_types_update = true; | bool Device::need_types_update = true; | ||||
| bool Device::need_devices_update = true; | bool Device::need_devices_update = true; | ||||
| vector<DeviceType> Device::types; | |||||
| vector<DeviceInfo> Device::devices; | |||||
| /* Device Requested Features */ | /* Device Requested Features */ | ||||
| std::ostream& operator <<(std::ostream &os, | std::ostream& operator <<(std::ostream &os, | ||||
| const DeviceRequestedFeatures& requested_features) | const DeviceRequestedFeatures& requested_features) | ||||
| { | { | ||||
| os << "Experimental features: " | os << "Experimental features: " | ||||
| << (requested_features.experimental ? "On" : "Off") << std::endl; | << (requested_features.experimental ? "On" : "Off") << std::endl; | ||||
| ▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | string Device::string_from_type(DeviceType type) | ||||
| else if(type == DEVICE_MULTI) | else if(type == DEVICE_MULTI) | ||||
| return "multi"; | return "multi"; | ||||
| return ""; | return ""; | ||||
| } | } | ||||
| vector<DeviceType>& Device::available_types() | vector<DeviceType>& Device::available_types() | ||||
| { | { | ||||
| static vector<DeviceType> types; | |||||
| if(need_types_update) { | if(need_types_update) { | ||||
| types.clear(); | types.clear(); | ||||
| types.push_back(DEVICE_CPU); | types.push_back(DEVICE_CPU); | ||||
| #ifdef WITH_CUDA | #ifdef WITH_CUDA | ||||
| if(device_cuda_init()) | if(device_cuda_init()) | ||||
| types.push_back(DEVICE_CUDA); | types.push_back(DEVICE_CUDA); | ||||
| #endif | #endif | ||||
| Show All 13 Lines | #endif | ||||
| need_types_update = false; | need_types_update = false; | ||||
| } | } | ||||
| return types; | return types; | ||||
| } | } | ||||
| vector<DeviceInfo>& Device::available_devices() | vector<DeviceInfo>& Device::available_devices() | ||||
| { | { | ||||
| static vector<DeviceInfo> devices; | |||||
| if(need_devices_update) { | if(need_devices_update) { | ||||
| devices.clear(); | devices.clear(); | ||||
| #ifdef WITH_CUDA | #ifdef WITH_CUDA | ||||
| if(device_cuda_init()) | if(device_cuda_init()) | ||||
| device_cuda_info(devices); | device_cuda_info(devices); | ||||
| #endif | #endif | ||||
| #ifdef WITH_OPENCL | #ifdef WITH_OPENCL | ||||
| Show All 39 Lines | |||||
| } | } | ||||
| void Device::tag_update() | void Device::tag_update() | ||||
| { | { | ||||
| need_types_update = true; | need_types_update = true; | ||||
| need_devices_update = true; | need_devices_update = true; | ||||
| } | } | ||||
| void Device::free_memory() | |||||
| { | |||||
| types.free_memory(); | |||||
| devices.free_memory(); | |||||
| } | |||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||