Forum Discussion
RemyaP_Intel
New Contributor
3 years agoHi,
Please follow the below steps to run matrix_mul in the FPGA emulator(in oneAPI DevCloud).
Step 1: Under matrix_multiplication folder:
- Create build_fpga_emu.sh
#!/bin/bash #PBS -l nodes=1:fpga_compile:ppn=2 #PBS -d . source /opt/intel/oneapi/setvars.sh > /dev/null 2>&1 echo echo start: $(date "+%y/%m/%d %H:%M:%S.%3N") echo make fpga_emu -f Makefile.fpga echo echo stop: $(date "+%y/%m/%d %H:%M:%S.%3N") echo - Create run_fpga_emu.sh.
#!/bin/bash #PBS -l nodes=1:fpga_compile:ppn=2 #PBS -d . source /opt/intel/oneapi/setvars.sh > /dev/null 2>&1 echo echo start: $(date "+%y/%m/%d %H:%M:%S.%3N") echo make run_emu -f Makefile.fpga echo echo end: $(date "+%y/%m/%d %H:%M:%S.%3N") echo
- Create Makefile.fpga and paste the contents as below:
CXX := dpcpp CXXFLAGS = -O2 -g -std=c++17 SRC := src/matrix_mul_dpcpp.cpp .PHONY: fpga_emu run_emu clean fpga_emu: matrix_mul_dpcpp.fpga_emu report: matrix_mul_dpcpp.a matrix_mul_dpcpp.fpga_emu: $(SRC) $(CXX) $(CXXFLAGS) -fintelfpga $^ -o $@ -DFPGA_EMULATOR=1 a.o: $(SRC) $(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1 run_emu: matrix_mul_dpcpp.fpga_emu ./matrix_mul_dpcpp.fpga_emu dev.o: $(SRC) $(CXX) $(CXXFLAGS) -fintelfpga -c $^ -o $@ -DFPGA=1 clean: rm -rf *.o *.d *.out *.mon *.emu *.aocr *.aoco *.prj *.fpga_emu *.fpga_emu matrix_mul_dpcpp.fpga *.a
Step 2: Navigate to the src folder in matrix_mul
Step 3: Edit the matrix_mul_dpcpp.cpp file as below:
- Add in the header :
#include <sycl/ext/intel/fpga_extensions.hpp>
- Add the below under main() :
#if FPGA_EMULATOR // DPC++ extension: FPGA emulator selector on systems without FPGA card. ext::intel::fpga_emulator_selector d_selector; #elif FPGA // DPC++ extension: FPGA selector on systems with FPGA card. ext::intel::fpga_selector d_selector; #else // The default device selector will select the most performant device. default_selector d_selector; #endif
After editing and creating the above files run the below commands:
qsub -l nodes=1:fpga_compile:ppn=2 -d . build_fpga_emu.sh
qsub -l nodes=1:fpga_compile:ppn=2 -d . run_fpga_emu.sh
The result will be generated. Please try and let us know if you need any clarifications.
If this resolves your issue, make sure to accept this as a solution. This would help others with similar issues. Thank you!
Regards,
Remya Premdas