Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
378 Views

OneAPI FPGA C Math Function Support

Jump to solution

I have developing designs using the FPGA SDK for OpenCL using both the DevCloud and an on-premise solution. My designs have been fully compiled and executed without issue on either platform.

I have been exploring the use of dpcpp/OneAPI for FPGAs for the same designs I have developed with OpenCL. When compiling my dpcpp code for the CPU, the program compiles, executes, and the results are validated. When I target the FPGA emulator (-fintelfpga -DFPGA_EMULATOR), I receive the following compilation error:

 

Failed to build device program
Error: unimplemented function(s) used:
__svml_expf16 is undefined 
__svml_sqrtf16_mask is undefined 
__svml_sqrtf16 is undefined 
CompilerException Failed to parse IR
Error: Compiler Error: OpenCL kernel compile/link FAILED
clang++: error: fpga compiler command failed with exit code 1 (use -v to see invocation)

 

 

My kernel uses the C math functions exp(), sqrt(), and pow(). When removing the exp() and sqrt() functions, the program compiles fine and the FPGA emulation completes successfully. Is there something I am missing to include for the FPGA like oneMKL or is there a missing FPGA implementation for the exp() and sqrt() functions?

Any help would be appreciated. All of the OneAPI development is performed on the DevCloud. DPCPP version: 

 

Intel(R) oneAPI DPC++ Compiler 2021.1-beta07 (2020.5.0.0604)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /glob/development-tools/versions/oneapi/beta07/inteloneapi/compiler/latest/linux/bin

 

 

Thank you!


Accepted Solutions
Highlighted
Moderator
285 Views

The reason of the error is you will need cl::sycl::exp() 


oneAPI FPGA example designs that use math functions, for example the CCR example can be found here: https://gitlab.devtools.intel.com/ecosystem-dev-programs/oneapi-toolkits/oneapi-toolkit/-/blob/2021....


We will improve this documentation in https://software.intel.com/content/www/us/en/develop/documentation/oneapi-fpga-optimization-guide/to... as user do searching in there.


Thanks



View solution in original post

7 Replies
Highlighted
Moderator
361 Views

Hi,


You can refer to https://www.oneapi.com/ -> https://spec.oneapi.com/versions/latest/elements/oneMKL/source/domains/vm/sqrt.html?highlight=sqrt


If you had follow the syntax and still see the problem. Attached the files and steps for us for duplication.


Thanks,


0 Kudos
Highlighted
Novice
352 Views

Hi,

I see that according to the oneMKL source (GitHub) that FPGA accelerators are not supported. 

Like I mentioned previously, the code runs fine when the compile target is the CPU only. 

I cannot disclose the actual source; however, I have created a simple program that produces the same error. The file mathfunc.cpp contains a similar routine using the exp(), sqrt(), and pow() C math functions. 

Compile for CPU (throws no error) using: 

 

dpcpp -DCPU_HOST mathfunc.cpp -o program

 

Compile for FPGA Emulator using:

 

dpcpp -fintelfpga -DFPGA_EMULATOR mathfunc.cpp -o program

 

Which gives the error:

 

Failed to build device program
Error: unimplemented function(s) used:
__svml_expf16 is undefined 
__svml_sqrtf16 is undefined 
CompilerException Failed to parse IR
Error: Compiler Error: OpenCL kernel compile/link FAILED
clang++: error: fpga compiler command failed with exit code 1 (use -v to see invocation)

 

 To execute CPU or FPGA Emulator program:

 

./program

 

Thank you!

Note: I had to zip the source file in order to upload.

0 Kudos
Highlighted
Beginner
298 Views

I'm having the same problem with the test kernel sent by @lkljucaric . The issue persists when building RTL or hardware from mathfunc.cpp .

~RTL~
dpcpp -fintelfpga -fsycl-link mathfunc.cpp -o math.a -Xshardware
~hardware~
dpcpp -fintelfpga mathfunc.cpp -o math.out -Xshardware

The output points to an issue with "pow" and a missing log file in both cases.

cmath:418: Compiler Error: undefined reference to 'pow'
Error: Optimizer FAILED.
Refer to mathfunc-11bbfc/mathfunc_11bbfc.log for details.

clang++: error: fpga compiler command failed with exit code 1 (use -v to see invocation)

 

The log file referenced was not present in the working directory. Tests were performed on devcloud compute nodes.

0 Kudos
Highlighted
Moderator
294 Views

Will work on this and get back to you all


0 Kudos
Highlighted
Moderator
286 Views

The reason of the error is you will need cl::sycl::exp() 


oneAPI FPGA example designs that use math functions, for example the CCR example can be found here: https://gitlab.devtools.intel.com/ecosystem-dev-programs/oneapi-toolkits/oneapi-toolkit/-/blob/2021....


We will improve this documentation in https://software.intel.com/content/www/us/en/develop/documentation/oneapi-fpga-optimization-guide/to... as user do searching in there.


Thanks



View solution in original post

Highlighted
Novice
267 Views

Thanks Kenny. I appears the FPGA emulation is now working. Will test a full hardware compile soon.

FYI, I cannot access the GitLab link that you have posted.

Thank you again for the support!

0 Kudos
Highlighted
Moderator
198 Views

The examples are also on Github if they don’t have access to Gitlab: https://github.com/intel/BaseKit-code-samples/blob/master/FPGAExampleDesigns/crr/src/main.cpp#L447


In anyway, we will document this for future as well. Thanks


If you have further queries, kindly post a response in the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you with your follow-up questions. 


0 Kudos