Created
April 13, 2013 15:18
-
-
Save supermomonga/5378798 to your computer and use it in GitHub Desktop.
cyan.rb by 兄さん
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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