opencl_ruby_ffi 1.3.7 → 1.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/opencl_ruby_ffi.rb +1 -0
- data/lib/opencl_ruby_ffi/Buffer.rb +7 -1
- data/lib/opencl_ruby_ffi/CommandQueue.rb +10 -4
- data/lib/opencl_ruby_ffi/Context.rb +82 -20
- data/lib/opencl_ruby_ffi/Device.rb +90 -11
- data/lib/opencl_ruby_ffi/Event.rb +17 -17
- data/lib/opencl_ruby_ffi/Image.rb +7 -1
- data/lib/opencl_ruby_ffi/Kernel.rb +68 -58
- data/lib/opencl_ruby_ffi/Mem.rb +13 -7
- data/lib/opencl_ruby_ffi/Pipe.rb +8 -0
- data/lib/opencl_ruby_ffi/Platform.rb +36 -11
- data/lib/opencl_ruby_ffi/Program.rb +21 -17
- data/lib/opencl_ruby_ffi/SVM.rb +1 -1
- data/lib/opencl_ruby_ffi/Sampler.rb +7 -6
- data/lib/opencl_ruby_ffi/ext.rb +1 -0
- data/lib/opencl_ruby_ffi/intel/unified_shared_memory_preview.rb +67 -40
- data/lib/opencl_ruby_ffi/khr/device_uuid.rb +119 -0
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb +292 -98
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb +83 -173
- data/lib/opencl_ruby_ffi/opencl_ruby_ffi_library.rb +181 -0
- data/lib/opencl_ruby_ffi/opencl_types.rb +4 -0
- data/opencl_ruby_ffi.gemspec +2 -2
- metadata +6 -4
    
        data/lib/opencl_ruby_ffi/Mem.rb
    CHANGED
    
    | @@ -46,17 +46,17 @@ module OpenCL | |
| 46 46 |  | 
| 47 47 | 
             
                # Returns the Context associated to the Mem
         | 
| 48 48 | 
             
                def context
         | 
| 49 | 
            -
                   | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 49 | 
            +
                  @_context ||= begin
         | 
| 50 | 
            +
                   ptr = MemoryPointer::new( Context )
         | 
| 51 | 
            +
                    error = OpenCL.clGetMemObjectInfo(self, CONTEXT, Context.size, ptr, nil)
         | 
| 52 | 
            +
                    error_check(error)
         | 
| 53 | 
            +
                    Context::new( ptr.read_pointer )
         | 
| 54 | 
            +
                  end
         | 
| 54 55 | 
             
                end
         | 
| 55 56 |  | 
| 56 57 | 
             
                # Returns the Platform associated to the Mem
         | 
| 57 58 | 
             
                def platform
         | 
| 58 | 
            -
                   | 
| 59 | 
            -
                  @_platform = self.context.platform
         | 
| 59 | 
            +
                  @_platform ||= self.context.platform
         | 
| 60 60 | 
             
                end
         | 
| 61 61 |  | 
| 62 62 | 
             
                # Returns the texture_target argument specified in create_from_GL_texture for Mem
         | 
| @@ -130,11 +130,17 @@ module OpenCL | |
| 130 130 | 
             
                  extend InnerGenerator
         | 
| 131 131 |  | 
| 132 132 | 
             
                  get_info("Mem", :cl_bool, "uses_svm_pointer", true)
         | 
| 133 | 
            +
                end
         | 
| 134 | 
            +
             | 
| 135 | 
            +
                module OpenCL30
         | 
| 136 | 
            +
                  extend InnerGenerator
         | 
| 133 137 |  | 
| 138 | 
            +
                  get_info_array("Mem", :cl_mem_properties, "properties")
         | 
| 134 139 | 
             
                end
         | 
| 135 140 |  | 
| 136 141 | 
             
                register_extension( :v11,  OpenCL11, "platform.version_number >= 1.1" )
         | 
| 137 142 | 
             
                register_extension( :v20,  OpenCL20, "platform.version_number >= 2.0" )
         | 
| 143 | 
            +
                register_extension( :v30,  OpenCL30, "platform.version_number >= 3.0" )
         | 
| 138 144 |  | 
| 139 145 | 
             
              end
         | 
| 140 146 |  | 
    
        data/lib/opencl_ruby_ffi/Pipe.rb
    CHANGED
    
    | @@ -34,6 +34,14 @@ module OpenCL | |
| 34 34 | 
             
                get_info("Pipe", :cl_uint, "packet_size")
         | 
| 35 35 | 
             
                get_info("Pipe", :cl_uint, "max_packets")
         | 
| 36 36 |  | 
| 37 | 
            +
                module OpenCL30
         | 
| 38 | 
            +
                  extend InnerGenerator
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  get_info_array("Pipe", :cl_pipe_properties, "properties")
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                register_extension( :v30,  Pipe::OpenCL30, "platform.version_number >= 3.0" )
         | 
| 44 | 
            +
             | 
| 37 45 | 
             
              end
         | 
| 38 46 |  | 
| 39 47 | 
             
            end
         | 
| @@ -63,18 +63,18 @@ module OpenCL | |
| 63 63 |  | 
| 64 64 | 
             
              # Returns an Array of Platform containing the available OpenCL platforms
         | 
| 65 65 | 
             
              def self.get_platforms
         | 
| 66 | 
            -
                 | 
| 67 | 
            -
             | 
| 66 | 
            +
                @_platforms ||= begin
         | 
| 67 | 
            +
                  ptr1 = MemoryPointer::new(:cl_uint , 1)
         | 
| 68 68 |  | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
                 | 
| 69 | 
            +
                  error = clGetPlatformIDs(0, nil, ptr1)
         | 
| 70 | 
            +
                  error_check(error)
         | 
| 71 | 
            +
                  ptr2 = MemoryPointer::new(:pointer, ptr1.read_uint)
         | 
| 72 | 
            +
                  error = clGetPlatformIDs(ptr1.read_uint(), ptr2, nil)
         | 
| 73 | 
            +
                  error_check(error)
         | 
| 74 | 
            +
                  ptr2.get_array_of_pointer(0,ptr1.read_uint()).collect { |platform_ptr|
         | 
| 75 | 
            +
                    Platform::new(platform_ptr, false)
         | 
| 76 | 
            +
                  }
         | 
| 77 | 
            +
                end
         | 
| 78 78 | 
             
              end
         | 
| 79 79 |  | 
| 80 80 | 
             
              class << self
         | 
| @@ -181,8 +181,33 @@ module OpenCL | |
| 181 181 |  | 
| 182 182 | 
             
                end
         | 
| 183 183 |  | 
| 184 | 
            +
                module OpenCL30
         | 
| 185 | 
            +
                  extend InnerGenerator
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                  def numeric_version
         | 
| 188 | 
            +
                    ptr = MemoryPointer::new( :cl_version )
         | 
| 189 | 
            +
                    error = OpenCL.clGetPlatformInfo( self, NUMERIC_VERSION, 4, ptr, nil)
         | 
| 190 | 
            +
                    error_check(error)
         | 
| 191 | 
            +
                    return Version::from_int(ptr.read_cl_version)
         | 
| 192 | 
            +
                  end
         | 
| 193 | 
            +
             | 
| 194 | 
            +
                  def extensions_with_version
         | 
| 195 | 
            +
                    sz = MemoryPointer::new( :size_t )
         | 
| 196 | 
            +
                    error = OpenCL.clGetPlatformInfo( self, EXTENSIONS_WITH_VERSION, 0, nil, sz)
         | 
| 197 | 
            +
                    error_check(error)
         | 
| 198 | 
            +
                    sz = sz.read_size_t
         | 
| 199 | 
            +
                    ptr = MemoryPointer::new( sz )
         | 
| 200 | 
            +
                    error = OpenCL.clGetPlatformInfo( self, EXTENSIONS_WITH_VERSION, sz, ptr, nil)
         | 
| 201 | 
            +
                    error_check(error)
         | 
| 202 | 
            +
                    nvsz = NameVersion.size
         | 
| 203 | 
            +
                    return (sz/nvsz).times.collect { |i| NameVersion::new(ptr + i*nvsz) }
         | 
| 204 | 
            +
                  end
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                end
         | 
| 207 | 
            +
             | 
| 184 208 | 
             
                register_extension( :v12, OpenCL12, "version_number >= 1.2" )
         | 
| 185 209 | 
             
                register_extension( :v21, OpenCL21, "version_number >= 2.1" )
         | 
| 210 | 
            +
                register_extension( :v30, OpenCL30, "version_number >= 3.0" )
         | 
| 186 211 |  | 
| 187 212 | 
             
              end
         | 
| 188 213 |  | 
| @@ -280,7 +280,11 @@ module OpenCL | |
| 280 280 | 
             
                  build_status.each { |d,s|
         | 
| 281 281 | 
             
                    success |= true if s.to_i == BuildStatus::SUCCESS
         | 
| 282 282 | 
             
                  }
         | 
| 283 | 
            -
                   | 
| 283 | 
            +
                  begin
         | 
| 284 | 
            +
                    return "#<#{self.class.name}: #{success ? kernel_names : ""}>"
         | 
| 285 | 
            +
                  rescue
         | 
| 286 | 
            +
                    return "#<#{self.class.name}: >"
         | 
| 287 | 
            +
                  end
         | 
| 284 288 | 
             
                end
         | 
| 285 289 |  | 
| 286 290 | 
             
                alias_method :orig_method_missing, :method_missing
         | 
| @@ -304,17 +308,17 @@ module OpenCL | |
| 304 308 |  | 
| 305 309 | 
             
                # Returns the Platform associated with the Program
         | 
| 306 310 | 
             
                def platform
         | 
| 307 | 
            -
                   | 
| 308 | 
            -
                  @_platform = self.context.platform
         | 
| 311 | 
            +
                  @_platform ||= self.context.platform
         | 
| 309 312 | 
             
                end
         | 
| 310 313 |  | 
| 311 314 | 
             
                # Returns the Context the Program is associated to
         | 
| 312 315 | 
             
                def context
         | 
| 313 | 
            -
                   | 
| 314 | 
            -
             | 
| 315 | 
            -
             | 
| 316 | 
            -
             | 
| 317 | 
            -
             | 
| 316 | 
            +
                  @_context ||= begin
         | 
| 317 | 
            +
                    ptr = MemoryPointer::new( Context )
         | 
| 318 | 
            +
                    error = OpenCL.clGetProgramInfo(self, CONTEXT, Context.size, ptr, nil)
         | 
| 319 | 
            +
                    error_check(error)
         | 
| 320 | 
            +
                    Context::new( ptr.read_pointer )
         | 
| 321 | 
            +
                  end
         | 
| 318 322 | 
             
                end
         | 
| 319 323 |  | 
| 320 324 | 
             
                get_info("Program", :cl_uint, "num_devices", true)
         | 
| @@ -322,15 +326,15 @@ module OpenCL | |
| 322 326 |  | 
| 323 327 | 
             
                # Returns the Array of Device the Program is associated with
         | 
| 324 328 | 
             
                def devices
         | 
| 325 | 
            -
                   | 
| 326 | 
            -
             | 
| 327 | 
            -
             | 
| 328 | 
            -
             | 
| 329 | 
            -
             | 
| 330 | 
            -
             | 
| 331 | 
            -
             | 
| 332 | 
            -
             | 
| 333 | 
            -
                   | 
| 329 | 
            +
                  @_devices ||= begin
         | 
| 330 | 
            +
                    n = self.num_devices
         | 
| 331 | 
            +
                    ptr2 = MemoryPointer::new( Device, n )
         | 
| 332 | 
            +
                    error = OpenCL.clGetProgramInfo(self, DEVICES, Device.size*n, ptr2, nil)
         | 
| 333 | 
            +
                    error_check(error)
         | 
| 334 | 
            +
                    ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
         | 
| 335 | 
            +
                      Device::new(device_ptr)
         | 
| 336 | 
            +
                    }
         | 
| 337 | 
            +
                  end
         | 
| 334 338 | 
             
                end
         | 
| 335 339 |  | 
| 336 340 | 
             
                get_info("Program", :string, "source")
         | 
    
        data/lib/opencl_ruby_ffi/SVM.rb
    CHANGED
    
    | @@ -158,7 +158,7 @@ module OpenCL | |
| 158 158 | 
             
              # ==== Returns
         | 
| 159 159 | 
             
              #
         | 
| 160 160 | 
             
              # the Event associated with the command
         | 
| 161 | 
            -
              def self.enqueue_svm_memfill(command_queue, svm_ptr, pattern,  | 
| 161 | 
            +
              def self.enqueue_svm_memfill(command_queue, svm_ptr, pattern, options = {})
         | 
| 162 162 | 
             
                error_check(INVALID_OPERATION) if command_queue.context.platform.version_number < 2.0
         | 
| 163 163 | 
             
                num_events, events = get_event_wait_list( options )
         | 
| 164 164 | 
             
                pattern_size = pattern.size
         | 
| @@ -30,7 +30,7 @@ module OpenCL | |
| 30 30 | 
             
                  prop_size += 2 if options[:mip_filter_mode]
         | 
| 31 31 | 
             
                  prop_size += 2 if options[:lod_min]
         | 
| 32 32 | 
             
                  prop_size += 2 if options[:lod_max]
         | 
| 33 | 
            -
                  properties = MemoryPointer::new( : | 
| 33 | 
            +
                  properties = MemoryPointer::new( :cl_sampler_properties, prop_size )
         | 
| 34 34 | 
             
                  properties[0].write_cl_sampler_info( Sampler::NORMALIZED_COORDS )
         | 
| 35 35 | 
             
                  properties[1].write_cl_bool( normalized_coords )
         | 
| 36 36 | 
             
                  properties[2].write_cl_sampler_info( Sampler::ADDRESSING_MODE )
         | 
| @@ -71,11 +71,12 @@ module OpenCL | |
| 71 71 |  | 
| 72 72 | 
             
                # Returns the context associated with the Sampler
         | 
| 73 73 | 
             
                def context
         | 
| 74 | 
            -
                   | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 74 | 
            +
                  @_context ||= begin
         | 
| 75 | 
            +
                    ptr = MemoryPointer::new( Context )
         | 
| 76 | 
            +
                    error = OpenCL.clGetSamplerInfo(self, CONTEXT, Context.size, ptr, nil)
         | 
| 77 | 
            +
                    error_check(error)
         | 
| 78 | 
            +
                    Context::new( ptr.read_pointer )
         | 
| 79 | 
            +
                  end
         | 
| 79 80 | 
             
                end
         | 
| 80 81 |  | 
| 81 82 | 
             
                get_info("Sampler", :cl_uint, "reference_count")
         | 
    
        data/lib/opencl_ruby_ffi/ext.rb
    CHANGED
    
    
| @@ -228,6 +228,23 @@ module OpenCL | |
| 228 228 | 
             
                  get_info("Device", :cl_unified_shared_memory_capabilities_intel, "device_shared_mem_capabilities_intel")
         | 
| 229 229 | 
             
                  get_info("Device", :cl_unified_shared_memory_capabilities_intel, "cross_device_mem_capabilities_intel")
         | 
| 230 230 | 
             
                  get_info("Device", :cl_unified_shared_memory_capabilities_intel, "shared_system_mem_capabilities_intel")
         | 
| 231 | 
            +
             | 
| 232 | 
            +
                  def clGetDeviceGlobalVariablePointerINTEL
         | 
| 233 | 
            +
                    @_clGetDeviceGlobalVariablePointerINTEL ||= begin
         | 
| 234 | 
            +
                      p = platform.get_extension_function("clGetDeviceGlobalVariablePointerINTEL", :cl_int, [Device, Program, :string, :pointer, :pointer])
         | 
| 235 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 236 | 
            +
                      p
         | 
| 237 | 
            +
                    end
         | 
| 238 | 
            +
                  end
         | 
| 239 | 
            +
             | 
| 240 | 
            +
                  def get_global_variable_pointer_intel(program, name)
         | 
| 241 | 
            +
                    pSize = MemoryPointer::new(:size_t)
         | 
| 242 | 
            +
                    pAddr = MemoryPointer::new(:pointer)
         | 
| 243 | 
            +
                    error = clGetDeviceGlobalVariablePointerINTEL.call(self, program, name, pSize, pAddr)
         | 
| 244 | 
            +
                    error_check(error)
         | 
| 245 | 
            +
                    return USMPointer::new(pAddr.read_pointer.slice(0, pSize.read_size_t), self)
         | 
| 246 | 
            +
                  end
         | 
| 247 | 
            +
             | 
| 231 248 | 
             
                end
         | 
| 232 249 | 
             
                register_extension( :cl_intel_unified_shared_memory_preview, UnifiedSharedMemoryPreviewINTEL, "extensions.include?(\"cl_intel_unified_shared_memory_preview\")" )
         | 
| 233 250 | 
             
              end
         | 
| @@ -282,38 +299,43 @@ module OpenCL | |
| 282 299 | 
             
                  extend InnerGenerator
         | 
| 283 300 |  | 
| 284 301 | 
             
                  def clGetMemAllocInfoINTEL
         | 
| 285 | 
            -
                     | 
| 286 | 
            -
             | 
| 287 | 
            -
             | 
| 288 | 
            -
             | 
| 302 | 
            +
                    @_clGetMemAllocInfoINTEL ||= begin
         | 
| 303 | 
            +
                      p = platform.get_extension_function("clGetMemAllocInfoINTEL", :cl_int, [Context, :pointer, :cl_mem_info_intel, :size_t, :pointer, :pointer])
         | 
| 304 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 305 | 
            +
                      p
         | 
| 306 | 
            +
                    end
         | 
| 289 307 | 
             
                  end
         | 
| 290 308 |  | 
| 291 309 | 
             
                  def clHostMemAllocINTEL
         | 
| 292 | 
            -
                     | 
| 293 | 
            -
             | 
| 294 | 
            -
             | 
| 295 | 
            -
             | 
| 310 | 
            +
                    @_clHostMemAllocINTEL ||= begin
         | 
| 311 | 
            +
                      p = platform.get_extension_function("clHostMemAllocINTEL", :pointer, [Context, :pointer, :size_t, :cl_uint, :pointer])
         | 
| 312 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 313 | 
            +
                      p
         | 
| 314 | 
            +
                    end
         | 
| 296 315 | 
             
                  end
         | 
| 297 316 |  | 
| 298 317 | 
             
                  def clDeviceMemAllocINTEL
         | 
| 299 | 
            -
                     | 
| 300 | 
            -
             | 
| 301 | 
            -
             | 
| 302 | 
            -
             | 
| 318 | 
            +
                    @_clDeviceMemAllocINTEL ||= begin
         | 
| 319 | 
            +
                      p = platform.get_extension_function("clDeviceMemAllocINTEL", :pointer, [Context, Device, :pointer, :size_t, :cl_uint, :pointer])
         | 
| 320 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 321 | 
            +
                      p
         | 
| 322 | 
            +
                    end
         | 
| 303 323 | 
             
                  end
         | 
| 304 324 |  | 
| 305 325 | 
             
                  def clSharedMemAllocINTEL
         | 
| 306 | 
            -
                     | 
| 307 | 
            -
             | 
| 308 | 
            -
             | 
| 309 | 
            -
             | 
| 326 | 
            +
                    @_clSharedMemAllocINTEL ||= begin
         | 
| 327 | 
            +
                      p = platform.get_extension_function("clSharedMemAllocINTEL", :pointer, [Context, Device, :pointer, :size_t, :cl_uint, :pointer])
         | 
| 328 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 329 | 
            +
                      p
         | 
| 330 | 
            +
                    end
         | 
| 310 331 | 
             
                  end
         | 
| 311 332 |  | 
| 312 333 | 
             
                  def clMemFreeINTEL
         | 
| 313 | 
            -
                    return @_clMemFreeINTEL  | 
| 314 | 
            -
             | 
| 315 | 
            -
             | 
| 316 | 
            -
             | 
| 334 | 
            +
                    return @_clMemFreeINTEL ||= begin
         | 
| 335 | 
            +
                      p = platform.get_extension_function("clMemFreeINTEL", :cl_int, [Context, :pointer])
         | 
| 336 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 337 | 
            +
                      p
         | 
| 338 | 
            +
                    end
         | 
| 317 339 | 
             
                  end
         | 
| 318 340 |  | 
| 319 341 | 
             
                  def get_mem_properties_intel(properties)
         | 
| @@ -414,10 +436,11 @@ module OpenCL | |
| 414 436 | 
             
                  extend InnerGenerator
         | 
| 415 437 |  | 
| 416 438 | 
             
                  def clSetKernelArgMemPointerINTEL
         | 
| 417 | 
            -
                     | 
| 418 | 
            -
             | 
| 419 | 
            -
             | 
| 420 | 
            -
             | 
| 439 | 
            +
                    @_clSetKernelArgMemPointerINTEL ||= begin
         | 
| 440 | 
            +
                      p = context.platform.get_extension_function("clSetKernelArgMemPointerINTEL", :cl_int, Kernel, :cl_uint, :pointer)
         | 
| 441 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 442 | 
            +
                      p
         | 
| 443 | 
            +
                    end
         | 
| 421 444 | 
             
                  end
         | 
| 422 445 |  | 
| 423 446 | 
             
                  def set_arg_mem_pointer_intel(index, usm_pointer)
         | 
| @@ -508,31 +531,35 @@ module OpenCL | |
| 508 531 | 
             
                  extend InnerGenerator
         | 
| 509 532 |  | 
| 510 533 | 
             
                  def clEnqueueMemFillINTEL
         | 
| 511 | 
            -
                     | 
| 512 | 
            -
             | 
| 513 | 
            -
             | 
| 514 | 
            -
             | 
| 534 | 
            +
                    @_clEnqueueMemFillINTEL ||= begin
         | 
| 535 | 
            +
                      p = platform.get_extension_function("clEnqueueMemFillINTEL", :cl_int, [CommandQueue, :pointer, :pointer, :size_t, :size_t, :cl_uint, :pointer, :pointer])
         | 
| 536 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 537 | 
            +
                      p
         | 
| 538 | 
            +
                    end
         | 
| 515 539 | 
             
                  end
         | 
| 516 540 |  | 
| 517 541 | 
             
                  def clEnqueueMemcpyINTEL
         | 
| 518 | 
            -
                     | 
| 519 | 
            -
             | 
| 520 | 
            -
             | 
| 521 | 
            -
             | 
| 542 | 
            +
                    @_clEnqueueMemcpyINTEL ||= begin
         | 
| 543 | 
            +
                      p = platform.get_extension_function("clEnqueueMemcpyINTEL", :cl_int, [CommandQueue, :cl_bool, :pointer, :pointer, :size_t, :cl_uint, :pointer, :pointer])
         | 
| 544 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 545 | 
            +
                      p
         | 
| 546 | 
            +
                    end
         | 
| 522 547 | 
             
                  end
         | 
| 523 548 |  | 
| 524 549 | 
             
                  def clEnqueueMigrateMemINTEL
         | 
| 525 | 
            -
                     | 
| 526 | 
            -
             | 
| 527 | 
            -
             | 
| 528 | 
            -
             | 
| 550 | 
            +
                    @_clEnqueueMigrateMemINTEL ||= begin
         | 
| 551 | 
            +
                      p = platform.get_extension_function("clEnqueueMigrateMemINTEL", :cl_int, [CommandQueue, :pointer, :size_t, :cl_mem_migration_flags_intel, :cl_uint, :pointer, :pointer])
         | 
| 552 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 553 | 
            +
                      p
         | 
| 554 | 
            +
                    end
         | 
| 529 555 | 
             
                  end
         | 
| 530 556 |  | 
| 531 557 | 
             
                  def clEnqueueMemAdviseINTEL
         | 
| 532 | 
            -
                     | 
| 533 | 
            -
             | 
| 534 | 
            -
             | 
| 535 | 
            -
             | 
| 558 | 
            +
                    @_clEnqueueMemAdviseINTEL ||= begin
         | 
| 559 | 
            +
                      p = platform.get_extension_function("clEnqueueMemAdviseINTEL", :cl_int, [CommandQueue, :pointer, :size_t, :cl_mem_advice_intel, :cl_uint, :pointer, :pointer])
         | 
| 560 | 
            +
                      error_check(OpenCL::INVALID_OPERATION) unless p
         | 
| 561 | 
            +
                      p
         | 
| 562 | 
            +
                    end
         | 
| 536 563 | 
             
                  end
         | 
| 537 564 |  | 
| 538 565 | 
             
                  def enqueue_mem_fill_intel(usm_ptr, pattern, options = {})
         | 
| @@ -0,0 +1,119 @@ | |
| 1 | 
            +
            using OpenCLRefinements if RUBY_VERSION.scan(/\d+/).collect(&:to_i).first >= 2
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module OpenCL
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              UUID_SIZE_KHR = 16
         | 
| 6 | 
            +
              LUID_SIZE_KHR = 8
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              DEVICE_UUID_KHR = 0x106A
         | 
| 9 | 
            +
              DRIVER_UUID_KHR = 0x106B
         | 
| 10 | 
            +
              DEVICE_LUID_VALID_KHR = 0x106C
         | 
| 11 | 
            +
              DEVICE_LUID_KHR = 0x106D
         | 
| 12 | 
            +
              DEVICE_NODE_MASK_KHR = 0x106E
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              class UUID < Struct
         | 
| 15 | 
            +
                layout :id, [ OpenCL.find_type(:cl_uchar), UUID_SIZE_KHR ]
         | 
| 16 | 
            +
                def to_s
         | 
| 17 | 
            +
                  a = self[:id].to_a
         | 
| 18 | 
            +
                  s = ""
         | 
| 19 | 
            +
                  s << "%02x" % a[15]
         | 
| 20 | 
            +
                  s << "%02x" % a[14]
         | 
| 21 | 
            +
                  s << "%02x" % a[13]
         | 
| 22 | 
            +
                  s << "%02x" % a[12]
         | 
| 23 | 
            +
                  s << "-"
         | 
| 24 | 
            +
                  s << "%02x" % a[11]
         | 
| 25 | 
            +
                  s << "%02x" % a[10]
         | 
| 26 | 
            +
                  s << "-"
         | 
| 27 | 
            +
                  s << "%02x" % a[9]
         | 
| 28 | 
            +
                  s << "%02x" % a[8]
         | 
| 29 | 
            +
                  s << "-"
         | 
| 30 | 
            +
                  s << "%02x" % a[7]
         | 
| 31 | 
            +
                  s << "%02x" % a[6]
         | 
| 32 | 
            +
                  s << "-"
         | 
| 33 | 
            +
                  s << "%02x" % a[5]
         | 
| 34 | 
            +
                  s << "%02x" % a[4]
         | 
| 35 | 
            +
                  s << "%02x" % a[3]
         | 
| 36 | 
            +
                  s << "%02x" % a[2]
         | 
| 37 | 
            +
                  s << "%02x" % a[1]
         | 
| 38 | 
            +
                  s << "%02x" % a[0]
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                def self.from_string(uuid)
         | 
| 42 | 
            +
                  new.from_string(uuid)
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                def from_string(uuid)
         | 
| 46 | 
            +
                  m = uuid.match(/(\h\h)(\h\h)(\h\h)(\h\h)-(\h\h)(\h\h)-(\h\h)(\h\h)-(\h\h)(\h\h)-(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)/)
         | 
| 47 | 
            +
                  raise "invalid format" unless m
         | 
| 48 | 
            +
                  UUID_SIZE_KHR.times { |i|
         | 
| 49 | 
            +
                    self[:id][UUID_SIZE_KHR-1-i] = m[i+1].to_i(16)
         | 
| 50 | 
            +
                  }
         | 
| 51 | 
            +
                  self
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              class LUID < Struct
         | 
| 56 | 
            +
                layout :id, [ OpenCL.find_type(:cl_uchar), LUID_SIZE_KHR ]
         | 
| 57 | 
            +
                def to_s
         | 
| 58 | 
            +
                  a = self[:id].to_a
         | 
| 59 | 
            +
                  s = ""
         | 
| 60 | 
            +
                  s << "%02x" % a[7]
         | 
| 61 | 
            +
                  s << "%02x" % a[6]
         | 
| 62 | 
            +
                  s << "%02x" % a[5]
         | 
| 63 | 
            +
                  s << "%02x" % a[4]
         | 
| 64 | 
            +
                  s << "%02x" % a[3]
         | 
| 65 | 
            +
                  s << "%02x" % a[2]
         | 
| 66 | 
            +
                  s << "%02x" % a[1]
         | 
| 67 | 
            +
                  s << "%02x" % a[0]
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                def self.from_string(uuid)
         | 
| 71 | 
            +
                  new.from_string(uuid)
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                def from_string(uuid)
         | 
| 75 | 
            +
                  m = uuid.match(/(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)/)
         | 
| 76 | 
            +
                  raise "invalid format" unless m
         | 
| 77 | 
            +
                  LUID_SIZE_KHR.times { |i|
         | 
| 78 | 
            +
                    self[:id][LUID_SIZE_KHR-1-i] = m[i+1].to_i(16)
         | 
| 79 | 
            +
                  }
         | 
| 80 | 
            +
                  self
         | 
| 81 | 
            +
                end
         | 
| 82 | 
            +
              end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
              class Device
         | 
| 85 | 
            +
                UUID_KHR = 0x106A
         | 
| 86 | 
            +
                LUID_VALID_KHR = 0x106C
         | 
| 87 | 
            +
                LUID_KHR = 0x106D
         | 
| 88 | 
            +
                NODE_MASK_KHR = 0x106E
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                module KHRDeviceUUID
         | 
| 91 | 
            +
                  extend InnerGenerator
         | 
| 92 | 
            +
                  get_info("Device", :cl_bool, "luid_valid_khr")
         | 
| 93 | 
            +
                  get_info("Device", :cl_uint, "node_mask_khr")
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  def uuid_khr
         | 
| 96 | 
            +
                    id = UUID.new
         | 
| 97 | 
            +
                    error = OpenCL.clGetDeviceInfo( self, UUID_KHR, UUID_SIZE_KHR, id, nil)
         | 
| 98 | 
            +
                    error_check(error)
         | 
| 99 | 
            +
                    return id
         | 
| 100 | 
            +
                  end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  def driver_uuid_khr
         | 
| 103 | 
            +
                    id = UUID.new
         | 
| 104 | 
            +
                    error = OpenCL.clGetDeviceInfo( self, DRIVER_UUID_KHR, UUID_SIZE_KHR, id, nil)
         | 
| 105 | 
            +
                    error_check(error)
         | 
| 106 | 
            +
                    return id
         | 
| 107 | 
            +
                  end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                  def luid_khr
         | 
| 110 | 
            +
                    id = LUID.new
         | 
| 111 | 
            +
                    error = OpenCL.clGetDeviceInfo( self, LUID_KHR, LUID_SIZE_KHR, id, nil)
         | 
| 112 | 
            +
                    error_check(error)
         | 
| 113 | 
            +
                    return id
         | 
| 114 | 
            +
                  end
         | 
| 115 | 
            +
                end
         | 
| 116 | 
            +
                register_extension( :cl_khr_device_uuid, KHRDeviceUUID, "extensions.include?(\"cl_khr_device_uuid\")" )
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
            end
         |