Skip to content

Commit

Permalink
Clear OpenCL buffers to all 0's after allocating
Browse files Browse the repository at this point in the history
  • Loading branch information
brichard19 committed Nov 23, 2018
1 parent bbeb697 commit 5219fe7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions clUtil/clContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cl_mem cl::CLContext::malloc(size_t size, cl_mem_flags flags)
cl_int err = 0;
cl_mem ptr = clCreateBuffer(_ctx, flags, size, NULL, &err);
clCall(err);

this->memset(ptr, 0, size);
return ptr;
}

Expand All @@ -70,9 +70,9 @@ void cl::CLContext::copyDeviceToHost(cl_mem devicePtr, void *hostPtr, size_t siz
clCall(clEnqueueReadBuffer(_queue, devicePtr, CL_TRUE, 0, size, hostPtr, 0, NULL, NULL));
}

void cl::CLContext::memset(cl_mem devicePtr, int value, size_t size)
void cl::CLContext::memset(cl_mem devicePtr, unsigned char value, size_t size)
{
clCall(clEnqueueFillBuffer(_queue, devicePtr, &value, sizeof(int), 0, size, NULL, NULL, NULL));
clCall(clEnqueueFillBuffer(_queue, devicePtr, &value, sizeof(unsigned char), 0, size, NULL, NULL, NULL));
}

cl::CLProgram::CLProgram(cl::CLContext &ctx, std::string srcFile) : _ctx(ctx)
Expand Down
2 changes: 1 addition & 1 deletion clUtil/clContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CLContext {

cl_mem malloc(size_t size, cl_mem_flags flags = CL_MEM_READ_WRITE);
void free(cl_mem mem);
void memset(cl_mem mem, int value, size_t size);
void memset(cl_mem mem, unsigned char value, size_t size);
void copyHostToDevice(const void *hostPtr, cl_mem devicePtr, size_t size);
void copyHostToDevice(const void *hostPtr, cl_mem devicePtr, size_t offset, size_t size);
void copyDeviceToHost(cl_mem devicePtr, void *hostPtr, size_t size);
Expand Down

0 comments on commit 5219fe7

Please sign in to comment.