Login  Register

Re: Why CLEventList has fixed size?

Posted by Wibowit on Mar 21, 2011; 12:27pm
URL: https://forum.jogamp.org/Why-CLEventList-has-fixed-size-tp2705613p2709682.html

Well, a HPC sector still uses Fortran :) It gives them highest performance sometimes. And it's relatively unlikely that HPC sector will use JOCL as Java isn't particularly suited for that kind of things.

The problem is that Java users are used to allocate many objects and then forget them (which is a good thing - managing global state is painful not only to user but also to machine) and you're making a library that performs poor with such scenarios. Additionally you're forcing users to manually deallocate objects - if you don't perform clReleaseEvent then it will reside in memory - a potential source of memory leak.

It is possible to automatically release Events: make a parent object for clones of the same Event and together with that Event store a reference to Event parent. In parent's finalize method we can release the Event.

Too bad that low-level OpenCL API accepts only arrays of cl_event objects. If they would also accept arrays of pointers to cl_event objects then managing them (at least from Java or C++) would be much easier - as far as I understand (or imagine) low-level API copies the cl_event arrays immediately on method invoaction, so providing pointers shouldn't cause any problem. Maybe I should write about it on Khronos forum?

> CLEvent implements CLEventHolder
> CLEventList implements CLEventHolder

No. I've meant separate CLEventHolder class with only one field of type CLEvent and accessors for it.

> Do you think the current static allocation leads to bad code style? How
> hard is it for you in your application to predict the event list size?

Certainly it leads. And, well, if you're making a standalone application then it could be possible to predict list sizes accurately enough, but what if I make a framework based on JOCL? It would require adding a lot of code to compute the sizes of lists to allocate.

I haven't written yet a full application but I plan to use graphs of Events - ie. for example many commands will wait for buffer to be uploaded. And some commands will wait for multiple Events. Current JOCL implementation doesn't faciliate it.


Edit:
I've looked to OpenCL headers. I don't know C good but statement:
typedef struct _cl_event *          cl_event;
looks like cl_event is in fact a pointer to some struct (sorry that I haven't figured it out earlier). That invalidates some of my previous statements. I will rethink the problem later.