dmsgnn / master-thesis

MLIR-based FPGA toolchain for Graph Neural Network acceleration using High-Level Synthesis. Developed for the Master of Science research thesis.
0 stars 0 forks source link

Sparse matmul accelerator #7

Closed dmsgnn closed 11 months ago

dmsgnn commented 1 year ago

description

This issue aims to document the steps needed to synthesize and accelerate a SpMSpM mul using PyTaco-MLIR.

Starting point of this work is -> https://github.com/sgh185/llvm-project/blob/sparse/docs.md

dmsgnn commented 1 year ago

generation of mlir

The first step is to clone the repository linked above Next, for Mac, delete line 9 of ENV.sh file and line 325-332 of file llvm/cmake/modules/HandleLLVMOptions.cmake.

Execute the two commands below

source ENV
./install.sh

Now it is possible to change directory to the taco one and run che codegen.py file. Example of generating a sparse matrix multiplication between two matrices of size $15 \times 15$ and $15 \times 16$

python3 codegen.py --sc-disable-omp --kernel SpMSpMMul --inps 15 15 16 --v 

Output files are located in the taco/output folder.

dmsgnn commented 1 year ago

synthesis

Tried to synthesize the SpMSpMMul.Z.0.lowered.ll file using the following command

./bambu-2023.8-dev.AppImage -v4 --print-dot -lm --soft-float -fno-unroll-loops \
     --compiler=I386_CLANG16 --device-name=xcu280-2Lfsvh2892-VVD --clock-period=4 \
     --experimental-setup=BAMBU-BALANCED-MP --channels-number=2 \
     --memory-allocation-policy=ALL_BRAM --disable-function-proxy  \
     --simulator=VERILATOR --top-fname=SpMSpMMul.Z.0.main \
     input.ll 2>&1 | tee bambu-log

but it led to the following error

1 warning generated.
/data2/home/demasi/taco/input.ll:4:9: warning: ptr type is only supported in -opaque-pointers mode
declare ptr @malloc(i64)
        ^
/data2/home/demasi/taco/input.ll:4:9: error: expected type
declare ptr @malloc(i64)
        ^
1 error generated.
warning: overriding the module target triple with i386-unknown-linux-gnu [-Woverride-module]
1 warning generated.
Error in compilation
/data2/home/demasi/taco/input.ll:4:9: warning: ptr type is only supported in -opaque-pointers mode
declare ptr @malloc(i64)
        ^
/data2/home/demasi/taco/input.ll:4:9: error: expected type
declare ptr @malloc(i64)
        ^
1 error generated.
error -> Front-end compiler returns an error during compilation 2
dmsgnn commented 1 year ago

synthesis successful

The following command completed successfully the synthesis

./bambu-2023.8-dev.AppImage -v4 --print-dot -lm --soft-float -fno-unroll-loops \ 
       --compiler=I386_CLANG16 --device-name=xcu280-2Lfsvh2892-VVD --clock-period=4 \
       --experimental-setup=BAMBU-BALANCED-MP --channels-number=2 \
       --memory-allocation-policy=ALL_BRAM --disable-function-proxy --simulator=VERILATOR \
       --top-fname=_mlir_ciface_SpMSpMMul.Z.0.main input.ll 2>&1 | tee bambu-log