Skip to content

Instantly share code, notes, and snippets.

@supermomonga
Created April 13, 2013 15:18
Show Gist options
  • Save supermomonga/5378798 to your computer and use it in GitHub Desktop.
Save supermomonga/5378798 to your computer and use it in GitHub Desktop.
cyan.rb by 兄さん
require 'fiddle/import'
module Cyan
CL_PLATFORM_VERSION = 0x0901
extend Fiddle::Importer
dlload 'opencl'
extern 'int clGetPlatformIDs(uint,intptr_t**,uint*)'
extern 'int clGetPlatformInfo(intptr_t,uint,size_t,void*,size_t*)'
num_platforms = value('uint')
clGetPlatformIDs(0,nil,num_platforms)
platforms = value('intptr_t[%u]' % num_platforms.value)
clGetPlatformIDs(num_platforms.value,platforms,nil)
platforms.value.each do |pid|
param_value_size = value('size_t')
clGetPlatformInfo(pid,CL_PLATFORM_VERSION,0,nil,param_value_size)
param = value('char[%u]' % param_value_size.value)
clGetPlatformInfo(pid,CL_PLATFORM_VERSION,param_value_size.value,param,nil)
print param.value.pack('c*')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment