taco icon indicating copy to clipboard operation
taco copied to clipboard

Is it possible to generate OpenCL kernels with TACO?

Open rdguerrerom opened this issue 2 years ago • 6 comments

Could TACO be used to generate OpenCL kernels? If not, what should be modified to allow OpenCL kernel generation?

rdguerrerom avatar Jan 24 '23 12:01 rdguerrerom

In theory TACO could be used to generate OpenCL kernels, but cannot currently. If you were interested in such a thing, looking at codegen_cuda.cpp would be the place to start. It lowers a loop-based intermediate representation into CUDA code. If your goal is to target AMD GPUs, targeting HIP would be the easiest thing instead, as you could just replace all of the CUDA calls with the corresponding HIP calls.

rohany avatar Jan 24 '23 17:01 rohany

Thanks a lot for answering,

The goal that I have in mind is to use FPGAs for which I think that the code generation shall target OpenCL-C.

rdguerrerom avatar Jan 24 '23 18:01 rdguerrerom

Targeting different kinds of hardware will likely be more work than just adjusting the code generator. @weiya711 has been working on mapping TACO down to CGRA's and other accelerators and can comment more.

rohany avatar Jan 24 '23 18:01 rohany

Yes, I agree with you @rohany. However, initially being able to generate kernels in OpenCL-C will suffice. Will a sensible modification of codegen_cuda.cpp be enough to accomplish this task?

rdguerrerom avatar Jan 24 '23 18:01 rdguerrerom

I've never written OpenCL targeting FPGA's before, so I cannot say for certain. The farther away this programming model moves from the threaded style of GPU programming the harder it will be to accomplish your task with just a change to the code generator. As Olivia has done in her work, for different programming models, and entirely different compilation workflow is needed to effectively target them.

rohany avatar Jan 24 '23 18:01 rohany

Please allow me to insist. It will be sufficient to modify codegen_cuda.cpp in order to generate OpenCL-C code, The OpenCL-C standard is fully supported by OneAPI, which allows running a program on an FPGA in emulation mode for debugging and also allows for hardware compilation.

rdguerrerom avatar Jan 24 '23 18:01 rdguerrerom