Skip to content

Commit

Permalink
Add build support for GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed Dec 21, 2019
1 parent 9e86a14 commit c58be43
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
21 changes: 20 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,32 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
endif()

project(kvsp)
set(IYOKANL2_ENABLE_TFHE on)

if(KVSP_ENABLE_CUDA)
project(kvsp LANGUAGES CUDA CXX)
find_package(CUDA)
set(IYOKANL2_ENABLE_CUFHE on)
add_subdirectory(cuFHE/cufhe)
else(KVSP_ENABLE_CUDA)
project(kvsp)
set(IYOKANL2_ENABLE_CUFHE off)
endif(KVSP_ENABLE_CUDA)

add_subdirectory(cahp-sim)
add_subdirectory(tfheutil)
add_subdirectory(tfhe/src)
add_subdirectory(Iyokan-L2)

if(KVSP_ENABLE_CUDA)
set_target_properties(iyokanl2-cufhe
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
endif(KVSP_ENABLE_CUDA)

set_target_properties(cahp-sim tfheutil iyokanl2
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
Expand Down
28 changes: 23 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
SHELL=/bin/bash
NCORES=$(shell grep cpu.cores /proc/cpuinfo | sort -u | sed 's/[^0-9]//g')

all: prepare build/kvsp build/tools build/share/kvsp/vsp-core.json build/llvm-cahp build/cahp-rt
cpu: common build/tools

gpu: common build/tools_gpu

common: prepare build/kvsp build/share/kvsp/vsp-core.json build/llvm-cahp build/cahp-rt

prepare: FORCE
mkdir -p build/bin
Expand All @@ -20,17 +24,31 @@ build/tools: FORCE
-DENABLE_FFTW=off \
-DENABLE_NAYUKI_PORTABLE=off -DENABLE_NAYUKI_AVX=off \
-DENABLE_SPQLIOS_AVX=on -DENABLE_SPQLIOS_FMA=off \
-DKVSP_ENABLE_CUDA=off \
../.. && \
make -j $$(( $(NCORES) + 1 ))
cp build/tools/bin/* build/bin/

build/tools_gpu: FORCE
mkdir -p build/tools_gpu
cd build/tools_gpu && \
cmake \
-DCMAKE_BUILD_TYPE="Release" \
-DENABLE_FFTW=off \
-DENABLE_NAYUKI_PORTABLE=off -DENABLE_NAYUKI_AVX=off \
-DENABLE_SPQLIOS_AVX=on -DENABLE_SPQLIOS_FMA=off \
-DKVSP_ENABLE_CUDA=on \
../.. && \
make -j $$(( $(NCORES) + 1 ))
cp build/tools_gpu/bin/* build/bin/

build/core: FORCE
cp -r cahp-diamond build/core
rsync -a --delete cahp-diamond/ build/core/
cd build/core && sbt run

build/share/kvsp/vsp-core.json: build/core FORCE
cp -r Iyokan-L1 build/Iyokan-L1
cp build/core/VSPCore.v build/Iyokan-L1
cp -r Iyokan-L1 build/
cp build/core/VSPCore.v build/Iyokan-L1/
cd build/Iyokan-L1 && \
yosys build.ys && \
dotnet run vsp-core.json vsp-core-converted.json
Expand All @@ -49,7 +67,7 @@ build/llvm-cahp: FORCE
cp build/llvm-cahp/bin/* build/bin/

build/cahp-rt: build/llvm-cahp FORCE
cp -r cahp-rt build/cahp-rt
cp -r cahp-rt build/
cd build/cahp-rt && CC=../llvm-cahp/bin/clang make
mkdir -p build/share/kvsp/cahp-rt
cd build/cahp-rt && \
Expand Down

0 comments on commit c58be43

Please sign in to comment.