Skip to content

Commit

Permalink
added put/setNullArg(int size) for setting NULL ranges as kernel argu…
Browse files Browse the repository at this point in the history
…ment to CLKernel.

added missing flush() to CLCommandQueue.
added CLMemory.getCapacity() utility method.
  • Loading branch information
mbien committed Mar 1, 2010
1 parent a0bc08e commit 63a97ef
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/com/mbien/opencl/CLCommandQueue.java
Expand Up @@ -989,6 +989,15 @@ public CLCommandQueue finish() {
return this;
}

/**
* Calls {@native clFlush}.
*/
public CLCommandQueue flush() {
int ret = cl.clFlush(ID);
checkForError(ret, "can not flush command queue");
return this;
}

/**
* Returns true only when {@link Mode#PROFILING_MODE} has been enabled.
*/
Expand Down
10 changes: 10 additions & 0 deletions src/com/mbien/opencl/CLKernel.java
Expand Up @@ -82,6 +82,11 @@ public CLKernel putArg(double value) {
return this;
}

public CLKernel putNullArg(int size) {
setNullArg(argIndex++, size);
return this;
}

public CLKernel putArgs(CLMemory<?>... values) {
setArgs(argIndex, values);
argIndex += values.length;
Expand Down Expand Up @@ -126,6 +131,11 @@ public CLKernel setArg(int argumentIndex, double value) {
return this;
}

public CLKernel setNullArg(int argumentIndex, int size) {
setArgument(argumentIndex, size, null);
return this;
}

public CLKernel setArgs(CLMemory<?>... values) {
setArgs(0, values);
return this;
Expand Down
12 changes: 11 additions & 1 deletion src/com/mbien/opencl/CLMemory.java
Expand Up @@ -76,7 +76,17 @@ public B getBuffer() {
}

/**
* Returns the size of the wrapped direct buffer in byte.
* Returns the capacity of the wrapped direct buffer or 0 if no buffer available.
*/
public int getCapacity() {
if(buffer == null) {
return 0;
}
return buffer.capacity();
}

/**
* Returns the size of the wrapped direct buffer in byte or 0 if no buffer available.
*/
public int getSize() {
if(buffer == null) {
Expand Down

0 comments on commit 63a97ef

Please sign in to comment.