I am trying to use Java Opencl from jruby, but I am facing a problem that I cannot solve, even with a big google search.
require 'java' require 'JOCL-0.1.7.jar' platforms = org.jocl.cl_platform_id.new puts platforms.class org.jocl.CL.clGetPlatformIDs(1, platforms, nil)
when I run this code using: jruby test.rb I get the following error when the last line is uncommented:
#<Class:0x10191777e> TypeError: cannot convert instance of class org.jruby.java.proxies.ConcreteJavaP roxy to class [Lorg.jocl.cl_platform_id; LukeTest at test.rb:29 (root) at test.rb:4
Just wondering if anyone has an idea on how to solve this problem?
EDIT: OK, so I think I solved the first part of this problem by making the platforms an array:
platforms = org.jocl.cl_platform_id[1].new
but this led to this error when adding the following two lines:
context_properties = org.jocl.cl_context_properties.new() context_properties.addProperty(org.jocl.CL::CL_CONTEXT_PLATFORM, platforms[0])
CodegenUtils.java:98:in `human': java.lang.NullPointerException from CodegenUtils.java:152:in `prettyParams' from CallableSelector.java:462:in `argumentError' from CallableSelector.java:436:in `argTypesDoNotMatch' from RubyToJavaInvoker.java:248:in `findCallableArityTwo' from InstanceMethodInvoker.java:66:in `call' from CachingCallSite.java:332:in `cacheAndCall' from CachingCallSite.java:203:in `call' from test.rb:36:in `module__0$RUBY$LukeTest' from test.rb:-1:in `module__0$RUBY$LukeTest' from test.rb:4:in `__file__' from test.rb:-1:in `load' from Ruby.java:679:in `runScript' from Ruby.java:672:in `runScript' from Ruby.java:579:in `runNormally' from Ruby.java:428:in `runFromMain' from Main.java:278:in `doRunFromMain' from Main.java:198:in `internalRun' from Main.java:164:in `run' from Main.java:148:in `run' from Main.java:128:in `main'
for some reason, when I print the platform class [0], it is listed as NilClass !?
source share