Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
641 Discussions

[oneapi] [fpga] "symbol multiply defined" for ap_float.hpp

jim31232
Novice
370 Views

Hi,

 

I'm trying to test a compile for FPGA with 16 bit floats.  These are defined in the header:

I took the ac_int sample and modified it to include the ap_float.hpp header.

ac_int sample:

https://github.com/oneapi-src/oneAPI-samples/tree/master/DirectProgramming/C++SYCL_FPGA/Tutorials/Features/ac_int

 

This works ok if have only one file.  If I have multiple includes however, I get the error below.  So something is wrong with the definition of this library.  The issue seems to only affect ap_float and not the other "ac_types". 

 

I'm building for FPGA (and FPGA_EMULATOR).  I've tried on oneapi 2024.1 and 2023.1.  I'm using Quartus 2023.1 as backend FPGA compiler.

 

If you drop the attached files into the src directory of the ac_int sample, you should be able to reproduce the error.

 

The offending line is in mydefs.h line 6.  If you remove that include then the compile will succeed.

 

Built as follows:

cd /my/path/to/ac_int

mkdir build

cd build

cmake ..

make

 

[ 16%] Building CXX object src/CMakeFiles/ac_int.fpga_emu.dir/ac_int.cpp.o
[ 33%] Building CXX object src/CMakeFiles/ac_int.fpga_emu.dir/mydefs.cpp.o
[ 50%] Linking CXX executable ../ac_int.fpga_emu
error: Linking globals named '_Z12get_exponentPKv': symbol multiply defined!
icpx: error: sycl-link command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/CMakeFiles/ac_int.fpga_emu.dir/build.make:113: ac_int.fpga_emu] Error 1
make[1]: *** [CMakeFiles/Makefile2:104: src/CMakeFiles/ac_int.fpga_emu.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

0 Kudos
4 Replies
jim31232
Novice
270 Views

I made the example simpler to exemplify the problem more directly.   The error given above remains the same.

The error manifests when the ap_float.hpp header is included.

If I try to build "by hand" (i.e. without CMake)  I get the same error:

icpx -fsycl -fintelfpga -qactypes -DFPGA_EMULATOR -Wall mydefs.cpp ac_int.cpp -o ac_int.exe

 

If I comment out the include on line 6 of mydefs.hpp and change the definition of MyFloat from ihc::bfloat16 to standard float, as below, then everything compiles fine.

 

#include <sycl/ext/intel/ac_types/ac_int.hpp>
//#include <sycl/ext/intel/ac_types/ap_float.hpp>
#include <sycl/ext/intel/fpga_extensions.hpp>

using MyInt14 = ac_int<14, true>;

using MyFloat = float;
//using MyFloat = ihc::bfloat16;

 

If I put all the code in one file, it compiles with the ap_float included without issue:

icpx -fsycl -fintelfpga -qactypes -DFPGA_EMULATOR -Wall onefile.cpp -o onefile.exe

 

 

0 Kudos
Alex_Y_Intel
Moderator
254 Views

I'm escalating your issue to our internal team and will work on it. 

0 Kudos
jim31232
Novice
179 Views

Hi Alex,

 

Thanks for taking a look.  Are you trying this on Windows?  Maybe you need this flag?  "/EHsc" is mentioned as necessary for Windows.  Maybe try adding that after the "-Wall " directive.

 

Karol.

 

 

 

 

 

 

0 Kudos
Alex_Y_Intel
Moderator
104 Views

I can reproduce your issue. Our internal team will work on it. 

0 Kudos
Reply