Comments (3)
IIRC, there had been a bit of hassle for "getting JExtract running" in the first place, but only due to the usual suspects (linux /
vs. windows \
path separators and such) - in general, I think it worked relatively smoothly.
And I'm at least aware that people already tried to use JExtract for OpenCL (quick searches bring things like https://mail.openjdk.org/pipermail/panama-dev/2020-January/007280.html , but I think that there also have been more detailed discussions). But I have not tried it out for myself. I could imagine that OpenCL might cause fewer headaches than CUDA. For example
- It does not mess together 10 libraries (like CUDA with CUBLAS, CUFFT, CUSPARSE etc)
- It has much less "legacy" aspects (nothing like CUBLAS vs. CUBLAS_v2 and such
(I mean, CUDA is version 12.4, and OpenCL is version 3.0...). - It has a much more clear distinction between "host- and GPU memory" - there is
cl_mem
, whereas CUDA is throwing around somevoid*
pointers where you never know what they are pointing to....
since it might require a higher level binding API like JOCL to make it user friendly!
I wouldn't call JOCL 'high-level'. It is still a 1:1 mapping of OpenCL. But of course, there are some design decisions in that already. I think that one very reasonable approach would be to generate these low-level 1:1 bindings with JExtract (and it does not matter whether they are "ugly" or "hard to use"), and then build a proper, object-oriented abstraction on top of that.
In fact, I think that OpenCL already does have a very "object-oriented" structure - but this structure is hidden under the necessity to create a plain, raw C-API. For example, looking at something like the JOCLReduction
sample, there's a lot of boilerplate code and low-level API access. But eventually, this could be implemented in Java with something that could be really, really close to something that could look like pseudocode:
CommandQueue queue = Magic.getPlatform().getContext().createQueue();
Kernel kernel = Magic.createKernel(sourceCode);
float inputData[] = ...;
float outputData[] = ...;
Mem inputMem= queue.copyToBuffer(inputData);
Mem outputMem= queue.createBuffer(outputData.length);
queue.launch(kernel, inputMem, outputMem);
queue.readBuffer(outputMem, ouputData);
I once started drafting such an OO-layer. But the design decisions that would have to go into such an OO layer would require a lot of time for planning, implementation, and testing. And eventually, the effort for maintaining many libraries may be prohibitively large. I've been maintaining JCuda and JOCL for 15 years. And ... it may have been useful for others. But if I hadn't done this, I'd be in the exact same place as I am now...
from jocl.
I did actually try out JExtract 5 years ago: https://mail.openjdk.org/pipermail/panama-dev/2019-February/004443.html
But beyond that, I have not been able to follow the developments of Panama recently (or rather: for quite a while now). I think that trying to "upgrade" JOCL or JCuda to use the new functionalities could be difficult. It would almost certainly be a "breaking change", on many levels. (E.g. the Pointer
class that is so central in both projects will probably no longer exist afterwards).
More generally, it's unlikely that I'll be able to allocate the time that would be necessary to investigate Panama, plan any implementation, and actually implement and maintain the projects based on the new infrastructure.
from jocl.
Thanks for the reply.
Great discussion with the panama team. Seems the API has changed considerable since then, like pointers are now MemorySegments with address long getter and other helpful native memory java functions, and also fewer classes now in one single package.
As I finished writing the original posts, I tested JExtract many times, with difficulty until I realised I need to install visual studio C++ tools to get the stdlib.h (Microsoft is absurd for this), and then succeeded in generating OpenCL bindings. I haven't tested the generated code, but it seems it has a lot of details which could be challenging to grasp without prior knowledge of FFM API and C. I might look at it one day in detail, since it might require a higher level binding API like JOCL to make it user friendly!
Anyway, I understand. Maintaining a library is not an easy task, furthermore, changing the design to accommodate new APIs is another stress level that requires time and resources.
from jocl.
Related Issues (20)
- JVM crash on call of org.jocl.CL.clEnquequeNDRangeKernelNative HOT 1
- Struct implementation HOT 8
- MIOpen OpenCL support (AMD's alternative to cuDNN)
- OpenCL 3.0 is here
- Build Failure Windows 10.0.18362.1016 HOT 5
- Debug Assertion Failed in File "xtree" HOT 6
- JOCL on Mac OS Big Sur & Apple Silicon M1 HOT 5
- Build failed on Ubuntu 18.04 (on mvn clean install) HOT 1
- cl_APPLE_gl_sharing bindings? HOT 5
- Trying to run any sample on osx big sur, results in "The function clCreateCommandQueueWithProperties is not supported" HOT 3
- Crashes my mac HOT 8
- [question] code signing on macos big sur HOT 3
- [Question] How to get platform and device information? HOT 1
- Native pointer address! HOT 3
- How to use JOCL
- How to use jocl on windows HOT 24
- Why is there no libJOCL_2_0_4-linux-arm64.so? HOT 35
- Google pixel support HOT 3
- SIGSEGV Erro during release
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jocl.