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

Logarithm Kernel #102

Closed
aaron-bray opened this issue Sep 29, 2022 · 5 comments
Closed

Logarithm Kernel #102

aaron-bray opened this issue Sep 29, 2022 · 5 comments

Comments

@aaron-bray
Copy link
Contributor

I know this is on your TODO list
I see there is a kernel for it already
I was wondering if we could work on this
Do you have any docs or examples of how to do this?

Thanks!

@StRigaud
Copy link
Member

Hi @aaron-bray

You are very welcome to participate in any form you see fit, adding a new kernel function is a good starting point!

The logarithm.cl kernel is ready to be integrated.
I do not have a documentation ready yet to adding it to Clic but this is not a complicated one and this issue can be a good starting point.

As I said here, I'm currently pushing a new version which change a bit some architecture and name aspect in the development branch. This should soon be merged to the master branch. So I would encourage you to work on a fork of the development branch and to do a PR once ready, so that your contribution is added to the next version.

For adding a new kernel:

Prior to anything, we need to have an OpenCL kernel code ready in the kernel repository. This is already the case here, so we can skip.

Then, we need to create a LogarithmKernel class (.hpp and .cpp) in the tier1 folder. If the new kernel were to rely on an already existing kernel in the tier1, we would add it to the tier2.
Here, you can happily copy the CopyKernel class, and replace the naming to fit the new kernel you are adding.

Important, the the OpenCL parameter names must be identical to the AddParameter() tag argument:

// cpp side
auto
CopyKernel::SetInput(const Image & object) -> void
{
  this->AddParameter("src", object);
}

auto
CopyKernel::SetOutput(const Image & object) -> void
{
  this->AddParameter("dst", object);
}

// opencl kernel side
__kernel void copy(
    IMAGE_src_TYPE  src,  // "src" tag name
    IMAGE_dst_TYPE  dst  // "dst" tag name
) 

Then we would need to add the Logarithm method function to the clesperanto class for user to easily access it.

Finally, add a test which should run the new kernel for all accepted data type and dimensions, to make sure that the kernel is actually running correctly (both the cpp code but also the ocl code).

Do not hesitate if some things are not clear or if you have more questions.

If I were to summarized:

@aaron-bray
Copy link
Contributor Author

Thank you for the information @StRigaud

This will be a slow burn effort for me, but I will keep you posted!

@StRigaud
Copy link
Member

StRigaud commented Oct 3, 2022

Do not hesitate to ask me with questions if you need too!

@StRigaud
Copy link
Member

StRigaud commented Nov 30, 2022

See this issues for more information on how to create a new kernel

@StRigaud
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants