Xilinx / gemx

Matrix Operation Library for FPGA https://xilinx.github.io/gemx/
Other
63 stars 21 forks source link

Measure the time of each step #5

Open ZhaoBaofu opened 6 years ago

ZhaoBaofu commented 6 years ago

Hi, I want to use the gemx program to compute matrix multiplication in FPGA . Here I want to know how to measure the execution time of these steps included: 1)read data from DDR to FPGA 2)compute matrix multiplication 3)write results from FPGA to DDR which command should I use ?

lisaliu1 commented 6 years ago

Please follow the steps below:

  1. navigate to gemx/ and then run following make command (make sure SDx 2017.4 env has been set up properly) make run_hw GEMX_ddrWidth=32 GEMX_XddrWidth=16 GEMX_keepMacBits=1 GEMX_argInstrWidth=1 GEMX_numKernels=1 GEMX_runGemv=0 GEMX_runGemm=1 GEMX_runTransp=0 GEMX_runSpmv=0 GEMX_gemmMBlocks=4 GEMX_gemmKBlocks=4 GEMX_gemmNBlocks=4 GEMX_splitMesh=1 GEMX_part=vcu1525 GEN_BIN_PROGRAM="gemm 512 512 512 512 512 512 512 1 0 A05 B05 C05 X05 gemm 1024 1024 1024 1024 1024 1024 1024 1 0 A1k B1k C1k X1K gemm 1024 1024 1024 1536 2048 2560 1024 1 0 A1kld B1kld C1kld X1kld"

In above command, the GEN_BIN_PROGRAM option describes the operations that will be executed on FPGA. For example, the first one, gemm 512 512 512 512 512 512 512 1 0 A05 B05 C05 X05 means operatopn C05 = ((A05 B05 + X05) 1) >> 0 will be executed on FPGA. Where A05, B05, X05 and C05 are 512 x 512 matrices. you can find the operation definition in src/gemx_gen_bin.cpp

  1. once the hw build finishes, run following command to launch the FPGA run. ./out_host/gemx_host.exe out_hw/gemx.xclbin out_host/app.bin out_hw/app_out.bin 2

  2. the results will show you the time you need. Look the main function of gemx_gen_bin.cpp, the source of gemx_host.exe, you will find the code to calculate this time intervals you need.

ZhaoBaofu commented 6 years ago

what should I do or which make command should I use when I want to run the hardware simulation of gemx ?

lisaliu1 commented 6 years ago

if you run make run_hw_em GEMX_ddrWidth=32 GEMX_XddrWidth=16 GEMX_keepMacBits=1 GEMX_argInstrWidth=1 GEMX_numKernels=1 GEMX_runGemv=0 GEMX_runGemm=1 GEMX_runTransp=0 GEMX_runSpmv=0 GEMX_gemmMBlocks=4 GEMX_gemmKBlocks=4 GEMX_gemmNBlocks=4 GEMX_splitMesh=1 GEMX_part=vcu1525 GEN_BIN_PROGRAM="gemm 512 512 512 512 512 512 512 1 0 A05 B05 C05 X05 "

you will see the hw emulation results for the instruction gemm 512 512 512 512 512 512 512 1 0 A05 B05 C05 X05 .

if you change run_hw_em to run_cpu_em, you will see cpu emulation results if you add HWEMUGUI=1 to the run_hw_em make command, you can see the waveform.