Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Update OpenCL wrapper to support 3D kernels #113

Merged
merged 7 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions libautoscoper/src/gpu/opencl/OpenCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,19 @@ void Kernel::grid2d(size_t X, size_t Y)
grid_[1] = Y * block_[1];
}

void Kernel::grid3d(size_t X, size_t Y, size_t Z) {
if (grid_dim_ && (grid_dim_ != 3)) {
jcfr marked this conversation as resolved.
Show resolved Hide resolved
ERROR("Grid dimension was already set and is not 3");
jcfr marked this conversation as resolved.
Show resolved Hide resolved
} else if (!block_dim_) {
ERROR("Must set block dimension before grid");
jcfr marked this conversation as resolved.
Show resolved Hide resolved
} else {
grid_dim_ = 3;
jcfr marked this conversation as resolved.
Show resolved Hide resolved
}
grid_[0] = X * block_[0];
grid_[1] = Y * block_[1];
grid_[2] = Z * block_[2];
}

void Kernel::block1d(size_t X)
{
if (block_dim_ && (block_dim_ != 1)) {
Expand All @@ -810,6 +823,18 @@ void Kernel::block2d(size_t X, size_t Y)
block_[1] = Y;
}

void Kernel::block3d(size_t X, size_t Y, size_t Z)
{
if (block_dim_ && (block_dim_ != 3)) {
ERROR("Block dimension was already set and is not 3");
jcfr marked this conversation as resolved.
Show resolved Hide resolved
} else {
block_dim_ = 3;
jcfr marked this conversation as resolved.
Show resolved Hide resolved
}
block_[0] = X;
block_[1] = Y;
block_[2] = Z;
}

void Kernel::addBufferArg(const Buffer* buf)
{
err_ = clSetKernelArg(kernel_, arg_index_++, sizeof(cl_mem), &buf->buffer_);
Expand Down
2 changes: 2 additions & 0 deletions libautoscoper/src/gpu/opencl/OpenCL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class Kernel
void block1d(size_t X);
void grid2d(size_t X, size_t Y);
void block2d(size_t X, size_t Y);
void grid3d(size_t X, size_t Y, size_t Z);
void block3d(size_t X, size_t Y, size_t Z);
void launch();

void addBufferArg(const Buffer* buf);
Expand Down