Forum Discussion

lkljucaric's avatar
lkljucaric
Icon for New Contributor rankNew Contributor
6 years ago
Solved

OneAPI FPGA C Math Function Support

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!

7 Replies

  • KennyT_altera's avatar
    KennyT_altera
    Icon for Super Contributor rankSuper Contributor

    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.1-beta08-ci/FPGAExampleDesigns/crr/src/main.cpp#L458


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


    Thanks



    • lkljucaric's avatar
      lkljucaric
      Icon for New Contributor rankNew Contributor

      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!

    • lkljucaric's avatar
      lkljucaric
      Icon for New Contributor rankNew Contributor

      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.

      • dcallanan's avatar
        dcallanan
        Icon for New Contributor rankNew Contributor

        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.

  • KennyT_altera's avatar
    KennyT_altera
    Icon for Super Contributor rankSuper Contributor

    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.