diff options
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/CMakeLists.txt | 2 | ||||
-rw-r--r-- | intern/cycles/device/device.cpp | 17 | ||||
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 18 | ||||
-rw-r--r-- | intern/cycles/device/device_cuda.cpp | 131 | ||||
-rw-r--r-- | intern/cycles/device/device_intern.h | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_multi.cpp | 13 | ||||
-rw-r--r-- | intern/cycles/device/device_opencl.cpp | 86 |
7 files changed, 120 insertions, 149 deletions
diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt index 318e4467e00..998b35351e3 100644 --- a/intern/cycles/device/CMakeLists.txt +++ b/intern/cycles/device/CMakeLists.txt @@ -11,6 +11,8 @@ set(INC set(INC_SYS ${GLEW_INCLUDE_PATH} + ../../../extern/cuew/include + ../../../extern/clew/include ) set(SRC diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index fa1f0acadde..efdfa98cfb5 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -20,12 +20,13 @@ #include "device.h" #include "device_intern.h" -#include "util_cuda.h" +#include "cuew.h" +#include "clew.h" + #include "util_debug.h" #include "util_foreach.h" #include "util_half.h" #include "util_math.h" -#include "util_opencl.h" #include "util_opengl.h" #include "util_time.h" #include "util_types.h" @@ -141,7 +142,7 @@ Device *Device::create(DeviceInfo& info, Stats &stats, bool background) break; #ifdef WITH_CUDA case DEVICE_CUDA: - if(cuLibraryInit()) + if(device_cuda_init()) device = device_cuda_create(info, stats, background); else device = NULL; @@ -159,7 +160,7 @@ Device *Device::create(DeviceInfo& info, Stats &stats, bool background) #endif #ifdef WITH_OPENCL case DEVICE_OPENCL: - if(clLibraryInit()) + if(device_opencl_init()) device = device_opencl_create(info, stats, background); else device = NULL; @@ -213,12 +214,12 @@ vector<DeviceType>& Device::available_types() types.push_back(DEVICE_CPU); #ifdef WITH_CUDA - if(cuLibraryInit()) + if(device_cuda_init()) types.push_back(DEVICE_CUDA); #endif #ifdef WITH_OPENCL - if(clLibraryInit()) + if(device_opencl_init()) types.push_back(DEVICE_OPENCL); #endif @@ -242,12 +243,12 @@ vector<DeviceInfo>& Device::available_devices() if(!devices_init) { #ifdef WITH_CUDA - if(cuLibraryInit()) + if(device_cuda_init()) device_cuda_info(devices); #endif #ifdef WITH_OPENCL - if(clLibraryInit()) + if(device_opencl_init()) device_opencl_info(devices); #endif diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 4fdeef6bdcb..fd5ae1d7828 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -435,7 +435,8 @@ public: if(system_cpu_support_avx2()) { for(int sample = 0; sample < task.num_samples; sample++) { for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) - kernel_cpu_avx2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x, sample); + kernel_cpu_avx2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, + task.shader_eval_type, x, task.offset, sample); if(task.get_cancel() || task_pool.canceled()) break; @@ -449,7 +450,8 @@ public: if(system_cpu_support_avx()) { for(int sample = 0; sample < task.num_samples; sample++) { for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) - kernel_cpu_avx_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x, sample); + kernel_cpu_avx_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, + task.shader_eval_type, x, task.offset, sample); if(task.get_cancel() || task_pool.canceled()) break; @@ -463,7 +465,8 @@ public: if(system_cpu_support_sse41()) { for(int sample = 0; sample < task.num_samples; sample++) { for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) - kernel_cpu_sse41_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x, sample); + kernel_cpu_sse41_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, + task.shader_eval_type, x, task.offset, sample); if(task.get_cancel() || task_pool.canceled()) break; @@ -477,7 +480,8 @@ public: if(system_cpu_support_sse3()) { for(int sample = 0; sample < task.num_samples; sample++) { for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) - kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x, sample); + kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, + task.shader_eval_type, x, task.offset, sample); if(task.get_cancel() || task_pool.canceled()) break; @@ -491,7 +495,8 @@ public: if(system_cpu_support_sse2()) { for(int sample = 0; sample < task.num_samples; sample++) { for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) - kernel_cpu_sse2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x, sample); + kernel_cpu_sse2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, + task.shader_eval_type, x, task.offset, sample); if(task.get_cancel() || task_pool.canceled()) break; @@ -504,7 +509,8 @@ public: { for(int sample = 0; sample < task.num_samples; sample++) { for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) - kernel_cpu_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x, sample); + kernel_cpu_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, + task.shader_eval_type, x, task.offset, sample); if(task.get_cancel() || task_pool.canceled()) break; diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index f0f32f87eed..1ed26717f4b 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -23,7 +23,7 @@ #include "buffers.h" -#include "util_cuda.h" +#include "cuew.h" #include "util_debug.h" #include "util_map.h" #include "util_opengl.h" @@ -61,65 +61,10 @@ public: return (CUdeviceptr)mem; } - static const char *cuda_error_string(CUresult result) + static bool have_precompiled_kernels() { - switch(result) { - case CUDA_SUCCESS: return "No errors"; - case CUDA_ERROR_INVALID_VALUE: return "Invalid value"; - case CUDA_ERROR_OUT_OF_MEMORY: return "Out of memory"; - case CUDA_ERROR_NOT_INITIALIZED: return "Driver not initialized"; - case CUDA_ERROR_DEINITIALIZED: return "Driver deinitialized"; - - case CUDA_ERROR_NO_DEVICE: return "No CUDA-capable device available"; - case CUDA_ERROR_INVALID_DEVICE: return "Invalid device"; - - case CUDA_ERROR_INVALID_IMAGE: return "Invalid kernel image"; - case CUDA_ERROR_INVALID_CONTEXT: return "Invalid context"; - case CUDA_ERROR_MAP_FAILED: return "Map failed"; - case CUDA_ERROR_UNMAP_FAILED: return "Unmap failed"; - case CUDA_ERROR_ARRAY_IS_MAPPED: return "Array is mapped"; - case CUDA_ERROR_ALREADY_MAPPED: return "Already mapped"; - case CUDA_ERROR_NO_BINARY_FOR_GPU: return "No binary for GPU"; - case CUDA_ERROR_ALREADY_ACQUIRED: return "Already acquired"; - case CUDA_ERROR_NOT_MAPPED: return "Not mapped"; - case CUDA_ERROR_NOT_MAPPED_AS_ARRAY: return "Mapped resource not available for access as an array"; - case CUDA_ERROR_NOT_MAPPED_AS_POINTER: return "Mapped resource not available for access as a pointer"; - case CUDA_ERROR_ECC_UNCORRECTABLE: return "Uncorrectable ECC error detected"; - case CUDA_ERROR_UNSUPPORTED_LIMIT: return "CUlimit not supported by device"; - case CUDA_ERROR_CONTEXT_ALREADY_IN_USE: return "Context already in use"; - case CUDA_ERROR_PEER_ACCESS_UNSUPPORTED: return "Peer access unsupported"; - case CUDA_ERROR_INVALID_PTX: return "Invalid PTX code"; - - case CUDA_ERROR_INVALID_SOURCE: return "Invalid source"; - case CUDA_ERROR_FILE_NOT_FOUND: return "File not found"; - case CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND: return "Link to a shared object failed to resolve"; - case CUDA_ERROR_SHARED_OBJECT_INIT_FAILED: return "Shared object initialization failed"; - case CUDA_ERROR_OPERATING_SYSTEM: return "OS call failed"; - - case CUDA_ERROR_INVALID_HANDLE: return "Invalid handle"; - - case CUDA_ERROR_NOT_FOUND: return "Not found"; - - case CUDA_ERROR_NOT_READY: return "CUDA not ready"; - - case CUDA_ERROR_ILLEGAL_ADDRESS: return "Illegal address"; - case CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES: return "Launch exceeded resources"; - case CUDA_ERROR_LAUNCH_TIMEOUT: return "Launch exceeded time out"; - case CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING: return "Launch with incompatible texturing"; - case CUDA_ERROR_HARDWARE_STACK_ERROR: return "Stack error"; - case CUDA_ERROR_ILLEGAL_INSTRUCTION: return "Illegal instruction"; - case CUDA_ERROR_MISALIGNED_ADDRESS: return "Misaligned address"; - case CUDA_ERROR_INVALID_ADDRESS_SPACE: return "Invalid address space"; - case CUDA_ERROR_INVALID_PC: return "Invalid program counter"; - case CUDA_ERROR_LAUNCH_FAILED: return "Launch failed"; - - case CUDA_ERROR_NOT_PERMITTED: return "Operation not permitted"; - case CUDA_ERROR_NOT_SUPPORTED: return "Operation not supported"; - - case CUDA_ERROR_UNKNOWN: return "Unknown error"; - - default: return "Unknown CUDA error value"; - } + string cubins_path = path_get("lib"); + return path_exists(cubins_path); } /*#ifdef NDEBUG @@ -141,7 +86,7 @@ public: CUresult result = stmt; \ \ if(result != CUDA_SUCCESS) { \ - string message = string_printf("CUDA error: %s in %s", cuda_error_string(result), #stmt); \ + string message = string_printf("CUDA error: %s in %s", cuewErrorString(result), #stmt); \ if(error_msg == "") \ error_msg = message; \ fprintf(stderr, "%s\n", message.c_str()); \ @@ -155,7 +100,7 @@ public: if(result == CUDA_SUCCESS) return false; - string message = string_printf("CUDA error at %s: %s", stmt.c_str(), cuda_error_string(result)); + string message = string_printf("CUDA error at %s: %s", stmt.c_str(), cuewErrorString(result)); if(error_msg == "") error_msg = message; fprintf(stderr, "%s\n", message.c_str()); @@ -252,14 +197,18 @@ public: return true; } - string compile_kernel() + string compile_kernel(bool experimental) { /* compute cubin name */ int major, minor; cuDeviceComputeCapability(&major, &minor, cuDevId); /* attempt to use kernel provided with blender */ - string cubin = path_get(string_printf("lib/kernel_sm_%d%d.cubin", major, minor)); + string cubin; + if(experimental) + cubin = path_get(string_printf("lib/kernel_experimental_sm_%d%d.cubin", major, minor)); + else + cubin = path_get(string_printf("lib/kernel_sm_%d%d.cubin", major, minor)); if(path_exists(cubin)) return cubin; @@ -267,7 +216,10 @@ public: string kernel_path = path_get("kernel"); string md5 = path_files_md5_hash(kernel_path); - cubin = string_printf("cycles_kernel_sm%d%d_%s.cubin", major, minor, md5.c_str()); + if(experimental) + cubin = string_printf("cycles_kernel_experimental_sm%d%d_%s.cubin", major, minor, md5.c_str()); + else + cubin = string_printf("cycles_kernel_sm%d%d_%s.cubin", major, minor, md5.c_str()); cubin = path_user_get(path_join("cache", cubin)); /* if exists already, use it */ @@ -275,7 +227,7 @@ public: return cubin; #ifdef _WIN32 - if(cuHavePrecompiledKernels()) { + if(have_precompiled_kernels()) { if(major < 2) cuda_error_message(string_printf("CUDA device requires compute capability 2.0 or up, found %d.%d. Your GPU is not supported.", major, minor)); else @@ -285,25 +237,25 @@ public: #endif /* if not, find CUDA compiler */ - string nvcc = cuCompilerPath(); + const char *nvcc = cuewCompilerPath(); - if(nvcc == "") { + if(nvcc == NULL) { cuda_error_message("CUDA nvcc compiler not found. Install CUDA toolkit in default location."); return ""; } - int cuda_version = cuCompilerVersion(); + int cuda_version = cuewCompilerVersion(); if(cuda_version == 0) { cuda_error_message("CUDA nvcc compiler version could not be parsed."); return ""; } - if(cuda_version < 50) { - printf("Unsupported CUDA version %d.%d detected, you need CUDA 6.0.\n", cuda_version/10, cuda_version%10); + if(cuda_version < 60) { + printf("Unsupported CUDA version %d.%d detected, you need CUDA 6.5.\n", cuda_version/10, cuda_version%10); return ""; } - else if(cuda_version != 60) - printf("CUDA version %d.%d detected, build may succeed but only CUDA 6.0 is officially supported.\n", cuda_version/10, cuda_version%10); + else if(cuda_version != 65) + printf("CUDA version %d.%d detected, build may succeed but only CUDA 6.5 is officially supported.\n", cuda_version/10, cuda_version%10); /* compile */ string kernel = path_join(kernel_path, "kernel.cu"); @@ -317,7 +269,10 @@ public: string command = string_printf("\"%s\" -arch=sm_%d%d -m%d --cubin \"%s\" " "-o \"%s\" --ptxas-options=\"-v\" -I\"%s\" -DNVCC -D__KERNEL_CUDA_VERSION__=%d", - nvcc.c_str(), major, minor, machine, kernel.c_str(), cubin.c_str(), include.c_str(), cuda_version); + nvcc, major, minor, machine, kernel.c_str(), cubin.c_str(), include.c_str(), cuda_version); + + if(experimental) + command += " -D__KERNEL_CUDA_EXPERIMENTAL__"; printf("%s\n", command.c_str()); @@ -348,7 +303,7 @@ public: return false; /* get kernel */ - string cubin = compile_kernel(); + string cubin = compile_kernel(experimental); if(cubin == "") return false; @@ -731,6 +686,7 @@ public: const int shader_chunk_size = 65536; const int start = task.shader_x; const int end = task.shader_x + task.shader_w; + int offset = task.offset; bool canceled = false; for(int sample = 0; sample < task.num_samples && !canceled; sample++) { @@ -743,6 +699,7 @@ public: &task.shader_eval_type, &shader_x, &shader_w, + &offset, &sample}; /* launch kernel */ @@ -1050,6 +1007,28 @@ public: } }; +bool device_cuda_init(void) +{ + static bool initialized = false; + static bool result = false; + + if (initialized) + return result; + + initialized = true; + + if (cuewInit() == CUEW_SUCCESS) { + if(CUDADevice::have_precompiled_kernels()) + result = true; +#ifndef _WIN32 + else if(cuewCompilerPath() != NULL) + result = true; +#endif + } + + return result; +} + Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background) { return new CUDADevice(info, stats, background); @@ -1063,13 +1042,13 @@ void device_cuda_info(vector<DeviceInfo>& devices) result = cuInit(0); if(result != CUDA_SUCCESS) { if(result != CUDA_ERROR_NO_DEVICE) - fprintf(stderr, "CUDA cuInit: %s\n", CUDADevice::cuda_error_string(result)); + fprintf(stderr, "CUDA cuInit: %s\n", cuewErrorString(result)); return; } result = cuDeviceGetCount(&count); if(result != CUDA_SUCCESS) { - fprintf(stderr, "CUDA cuDeviceGetCount: %s\n", CUDADevice::cuda_error_string(result)); + fprintf(stderr, "CUDA cuDeviceGetCount: %s\n", cuewErrorString(result)); return; } diff --git a/intern/cycles/device/device_intern.h b/intern/cycles/device/device_intern.h index 7eb66c25a81..80f1e2441a5 100644 --- a/intern/cycles/device/device_intern.h +++ b/intern/cycles/device/device_intern.h @@ -22,7 +22,9 @@ CCL_NAMESPACE_BEGIN class Device; Device *device_cpu_create(DeviceInfo& info, Stats &stats, bool background); +bool device_opencl_init(void); Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background); +bool device_cuda_init(void); Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background); Device *device_network_create(DeviceInfo& info, Stats &stats, const char *address); Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background); diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp index 564fbdbadf8..7f055c79491 100644 --- a/intern/cycles/device/device_multi.cpp +++ b/intern/cycles/device/device_multi.cpp @@ -280,7 +280,18 @@ public: int get_split_task_count(DeviceTask& task) { - return 1; + int total_tasks = 0; + list<DeviceTask> tasks; + task.split(tasks, devices.size()); + foreach(SubDevice& sub, devices) { + if(!tasks.empty()) { + DeviceTask subtask = tasks.front(); + tasks.pop_front(); + + total_tasks += sub.device->get_split_task_count(subtask); + } + } + return total_tasks; } void task_add(DeviceTask& task) diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index 3abda6a54c1..82419cd62b1 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -25,11 +25,12 @@ #include "buffers.h" +#include "clew.h" + #include "util_foreach.h" #include "util_map.h" #include "util_math.h" #include "util_md5.h" -#include "util_opencl.h" #include "util_opengl.h" #include "util_path.h" #include "util_time.h" @@ -334,63 +335,10 @@ public: bool device_initialized; string platform_name; - const char *opencl_error_string(cl_int err) - { - switch (err) { - case CL_SUCCESS: return "Success!"; - case CL_DEVICE_NOT_FOUND: return "Device not found."; - case CL_DEVICE_NOT_AVAILABLE: return "Device not available"; - case CL_COMPILER_NOT_AVAILABLE: return "Compiler not available"; - case CL_MEM_OBJECT_ALLOCATION_FAILURE: return "Memory object allocation failure"; - case CL_OUT_OF_RESOURCES: return "Out of resources"; - case CL_OUT_OF_HOST_MEMORY: return "Out of host memory"; - case CL_PROFILING_INFO_NOT_AVAILABLE: return "Profiling information not available"; - case CL_MEM_COPY_OVERLAP: return "Memory copy overlap"; - case CL_IMAGE_FORMAT_MISMATCH: return "Image format mismatch"; - case CL_IMAGE_FORMAT_NOT_SUPPORTED: return "Image format not supported"; - case CL_BUILD_PROGRAM_FAILURE: return "Program build failure"; - case CL_MAP_FAILURE: return "Map failure"; - case CL_INVALID_VALUE: return "Invalid value"; - case CL_INVALID_DEVICE_TYPE: return "Invalid device type"; - case CL_INVALID_PLATFORM: return "Invalid platform"; - case CL_INVALID_DEVICE: return "Invalid device"; - case CL_INVALID_CONTEXT: return "Invalid context"; - case CL_INVALID_QUEUE_PROPERTIES: return "Invalid queue properties"; - case CL_INVALID_COMMAND_QUEUE: return "Invalid command queue"; - case CL_INVALID_HOST_PTR: return "Invalid host pointer"; - case CL_INVALID_MEM_OBJECT: return "Invalid memory object"; - case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR: return "Invalid image format descriptor"; - case CL_INVALID_IMAGE_SIZE: return "Invalid image size"; - case CL_INVALID_SAMPLER: return "Invalid sampler"; - case CL_INVALID_BINARY: return "Invalid binary"; - case CL_INVALID_BUILD_OPTIONS: return "Invalid build options"; - case CL_INVALID_PROGRAM: return "Invalid program"; - case CL_INVALID_PROGRAM_EXECUTABLE: return "Invalid program executable"; - case CL_INVALID_KERNEL_NAME: return "Invalid kernel name"; - case CL_INVALID_KERNEL_DEFINITION: return "Invalid kernel definition"; - case CL_INVALID_KERNEL: return "Invalid kernel"; - case CL_INVALID_ARG_INDEX: return "Invalid argument index"; - case CL_INVALID_ARG_VALUE: return "Invalid argument value"; - case CL_INVALID_ARG_SIZE: return "Invalid argument size"; - case CL_INVALID_KERNEL_ARGS: return "Invalid kernel arguments"; - case CL_INVALID_WORK_DIMENSION: return "Invalid work dimension"; - case CL_INVALID_WORK_GROUP_SIZE: return "Invalid work group size"; - case CL_INVALID_WORK_ITEM_SIZE: return "Invalid work item size"; - case CL_INVALID_GLOBAL_OFFSET: return "Invalid global offset"; - case CL_INVALID_EVENT_WAIT_LIST: return "Invalid event wait list"; - case CL_INVALID_EVENT: return "Invalid event"; - case CL_INVALID_OPERATION: return "Invalid operation"; - case CL_INVALID_GL_OBJECT: return "Invalid OpenGL object"; - case CL_INVALID_BUFFER_SIZE: return "Invalid buffer size"; - case CL_INVALID_MIP_LEVEL: return "Invalid mip-map level"; - default: return "Unknown"; - } - } - bool opencl_error(cl_int err) { if(err != CL_SUCCESS) { - string message = string_printf("OpenCL error (%d): %s", err, opencl_error_string(err)); + string message = string_printf("OpenCL error (%d): %s", err, clewErrorString(err)); if(error_msg == "") error_msg = message; fprintf(stderr, "%s\n", message.c_str()); @@ -412,7 +360,7 @@ public: cl_int err = stmt; \ \ if(err != CL_SUCCESS) { \ - string message = string_printf("OpenCL error: %s in %s", opencl_error_string(err), #stmt); \ + string message = string_printf("OpenCL error: %s in %s", clewErrorString(err), #stmt); \ if(error_msg == "") \ error_msg = message; \ fprintf(stderr, "%s\n", message.c_str()); \ @@ -422,7 +370,7 @@ public: void opencl_assert_err(cl_int err, const char* where) { if(err != CL_SUCCESS) { - string message = string_printf("OpenCL error (%d): %s in %s", err, opencl_error_string(err), where); + string message = string_printf("OpenCL error (%d): %s in %s", err, clewErrorString(err), where); if(error_msg == "") error_msg = message; fprintf(stderr, "%s\n", message.c_str()); @@ -552,7 +500,7 @@ public: device_initialized = true; } - static void context_notify_callback(const char *err_info, + static void CL_CALLBACK context_notify_callback(const char *err_info, const void *private_info, size_t cb, void *user_data) { char name[256]; @@ -1056,6 +1004,7 @@ public: cl_int d_shader_eval_type = task.shader_eval_type; cl_int d_shader_x = task.shader_x; cl_int d_shader_w = task.shader_w; + cl_int d_offset = task.offset; /* sample arguments */ cl_uint narg = 0; @@ -1085,6 +1034,7 @@ public: opencl_assert(clSetKernelArg(kernel, narg++, sizeof(d_shader_eval_type), (void*)&d_shader_eval_type)); opencl_assert(clSetKernelArg(kernel, narg++, sizeof(d_shader_x), (void*)&d_shader_x)); opencl_assert(clSetKernelArg(kernel, narg++, sizeof(d_shader_w), (void*)&d_shader_w)); + opencl_assert(clSetKernelArg(kernel, narg++, sizeof(d_offset), (void*)&d_offset)); opencl_assert(clSetKernelArg(kernel, narg++, sizeof(d_sample), (void*)&d_sample)); enqueue_kernel(kernel, task.shader_w, 1); @@ -1162,6 +1112,26 @@ Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background) return new OpenCLDevice(info, stats, background); } +bool device_opencl_init(void) { + static bool initialized = false; + static bool result = false; + + if (initialized) + return result; + + initialized = true; + + // OpenCL disabled for now, only works with this environment variable set + if(!getenv("CYCLES_OPENCL_TEST")) { + result = false; + } + else { + result = clewInit() == CLEW_SUCCESS; + } + + return result; +} + void device_opencl_info(vector<DeviceInfo>& devices) { vector<cl_device_id> device_ids; |