module BOAST::OpenCLHelper
Constants
- CUDA_BLOCKDIM
- CUDA_BLOCKIDX
- CUDA_GRIDDIM
- CUDA_THREADIDX
- OCL_CUDA_DIM_ASSOC
Public Instance Methods
barrier(*locality)
click to toggle source
# File lib/BOAST/Language/BOAST_OpenCL.rb, line 14 def barrier(*locality) if lang == CL then if locality.include?(:local) and locality.include?(:global) then return FuncCall::new("barrier","CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE") elsif locality.include?(:local) then return FuncCall::new("barrier","CLK_LOCAL_MEM_FENCE") elsif locality.include?(:global) then return FuncCall::new("barrier","CLK_GLOBAL_MEM_FENCE") else raise "Unsupported locality" end elsif lang == CUDA then return FuncCall::new("__syncthreads") else raise "Unsupported language!" end end
get_global_id(dim)
click to toggle source
# File lib/BOAST/Language/BOAST_OpenCL.rb, line 52 def get_global_id(dim) if lang == CL then return FuncCall::new("get_global_id",dim, :return => Sizet) elsif lang == CUDA then d = OCL_CUDA_DIM_ASSOC[dim] raise "Unsupported dimension!" unless d return eval "CUDA_THREADIDX.#{d}+CUDA_BLOCKIDX.#{d}*CUDA_BLOCKDIM.#{d}" else raise "Unsupported language!" end end
get_global_size(dim)
click to toggle source
# File lib/BOAST/Language/BOAST_OpenCL.rb, line 40 def get_global_size(dim) if lang == CL then return FuncCall::new("get_global_size", dim, :return => Sizet) elsif lang == CUDA then d = OCL_CUDA_DIM_ASSOC[dim] raise "Unsupported dimension!" unless d return eval "CUDA_GRIDDIM.#{d}*CUDA_BLOCKDIM.#{d}" else raise "Unsupported language!" end end
get_group_id(dim)
click to toggle source
# File lib/BOAST/Language/BOAST_OpenCL.rb, line 100 def get_group_id(dim) if lang == CL then return FuncCall::new("get_group_id",dim, :return => Sizet) elsif lang == CUDA then d = OCL_CUDA_DIM_ASSOC[dim] raise "Unsupported dimension!" unless d return eval "CUDA_BLOCKIDX.#{d}" else raise "Unsupported language!" end end
get_local_id(dim)
click to toggle source
# File lib/BOAST/Language/BOAST_OpenCL.rb, line 76 def get_local_id(dim) if lang == CL then return FuncCall::new("get_local_id",dim, :return => Sizet) elsif lang == CUDA then d = OCL_CUDA_DIM_ASSOC[dim] raise "Unsupported dimension!" unless d return eval "CUDA_THREADIDX.#{d}" else raise "Unsupported language!" end end
get_local_size(dim)
click to toggle source
# File lib/BOAST/Language/BOAST_OpenCL.rb, line 64 def get_local_size(dim) if lang == CL then return FuncCall::new("get_local_size",dim, :return => Sizet) elsif lang == CUDA then d = OCL_CUDA_DIM_ASSOC[dim] raise "Unsupported dimension!" unless d return eval "CUDA_BLOCKDIM.#{d}" else raise "Unsupported language!" end end
get_num_groups(dim)
click to toggle source
# File lib/BOAST/Language/BOAST_OpenCL.rb, line 88 def get_num_groups(dim) if lang == CL then return FuncCall::new("get_num_groups",dim, :return => Sizet) elsif lang == CUDA then d = OCL_CUDA_DIM_ASSOC[dim] raise "Unsupported dimension!" unless d return eval "CUDA_GRIDDIM.#{d}" else raise "Unsupported language!" end end
get_work_dim()
click to toggle source
# File lib/BOAST/Language/BOAST_OpenCL.rb, line 32 def get_work_dim if lang == CL then return FuncCall::new("get_work_dim", :return => Int("wd", :signed => false)) else raise "Unsupported language!" end end