-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve efficiency of sparse queries (#94)
* Fix for gcc-13 * Add personalised makefile * Replace sort with priority queue * Missing semicolon * Type fixes for SparseDist * Add debug flag to makefile * Debug mode for Makefiles * Revert "Debug mode for Makefiles" This reverts commit 266742b. * Set debug another way * Allow debug to be turned off * Put the sort in the right place (after all dists done) * Replace hash map * Use C++17 * Correct header name * Typo in map header name * Replace class with struct * Try to fix order in sparse loop Definitely wrong! Was confused by brace levels * Change order to match with tests * Pass C++17 onto nvcc * Correct c++17 definition for CUDA * Add license for hashmap * Rename local build env var
- Loading branch information
Showing
20 changed files
with
2,279 additions
and
2,134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Martin Leitner-Ankerl | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
CXX=gcc-11 | ||
CC=gcc-11 | ||
CFLAGS+=-Wall -Wextra -fPIC | ||
CXXFLAGS+=-Wall -Wextra -std=c++17 -fopenmp -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -fPIC | ||
ifdef DEBUG | ||
CXXFLAGS+= -O0 -g | ||
CUDAFLAGS = -g -G | ||
else ifdef PROFILE | ||
CXXFLAGS+= -O2 -g -flto -fno-fat-lto-objects -fvisibility=hidden | ||
CUDAFLAGS = -O2 -pg -lineinfo | ||
else | ||
CXXFLAGS+= -march=native -O3 -flto -fno-fat-lto-objects -fvisibility=hidden | ||
CFLAGS+= -march=native -O3 -flto -fno-fat-lto-objects -fvisibility=hidden | ||
CUDAFLAGS+= -O3 | ||
endif | ||
|
||
UNAME_S := $(shell uname -s) | ||
LIBLOC = ${CONDA_PREFIX} | ||
LDLIBS = -lz -lhdf5_cpp -lhdf5 -lopenblas -lgomp | ||
ifeq ($(UNAME_S),Linux) | ||
CXXFLAGS+= -m64 | ||
ifdef PROFILE | ||
CXXFLAGS+= -Wl,--compress-debug-sections=none | ||
endif | ||
LDLIBS+= -lpthread -lgfortran -lm -ldl -lrt | ||
LDFLAGS=-Wl,-as-needed | ||
endif | ||
ifeq ($(UNAME_S),Darwin) | ||
LDLIBS+= -pthread | ||
endif | ||
|
||
CPPFLAGS+=-I"/home/linuxbrew/.linuxbrew/include" -I"." -I"../vendor/highfive/include" -I$(LIBLOC)/include -I$(LIBLOC)/include/eigen3 | ||
LDFLAGS+= -L$(LIBLOC)/lib -L"/home/linuxbrew/.linuxbrew/lib" -L/usr/local/cuda-12.3/lib64 | ||
CUDA_LDLIBS=-lcudadevrt -lcudart_static $(LDLIBS) | ||
|
||
CUDA_LDFLAGS =-L$(LIBLOC)/lib -L${CUDA_HOME}/targets/x86_64-linux/lib/stubs -L${CUDA_HOME}/targets/x86_64-linux/lib | ||
CUDAFLAGS +=-ccbin /home/linuxbrew/.linuxbrew/bin/g++-11 -std=c++17 -Xcompiler -fPIC --cudart static --relocatable-device-code=true --expt-relaxed-constexpr -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 | ||
ifdef GPU | ||
CXXFLAGS += -DGPU_AVAILABLE | ||
CUDAFLAGS += -gencode arch=compute_86,code=sm_86 | ||
CUDA_LDFLAGS += -L/usr/local/cuda-12.3/lib64 | ||
endif | ||
|
||
PYTHON_LIB = pp_sketchlib$(shell python3-config --extension-suffix) | ||
|
||
# python specific options | ||
python: CPPFLAGS += -DGPU_AVAILABLE -DPYTHON_EXT -DNDEBUG -Dpp_sketchlib_EXPORTS $(shell python3 -m pybind11 --includes) | ||
|
||
PROGRAMS=sketch_test matrix_test read_test gpu_dist_test | ||
|
||
SKETCH_OBJS=dist/dist.o dist/matrix_ops.o reference.o sketch/seqio.o sketch/sketch.o database/database.o sketch/countmin.o api.o dist/linear_regression.o random/rng.o random/random_match.o random/kmeans/KMeansRexCore.o random/kmeans/mersenneTwister2002.o | ||
GPU_SKETCH_OBJS=gpu/gpu_api.o | ||
CUDA_OBJS=gpu/dist.cu.o gpu/sketch.cu.o gpu/device_reads.cu.o gpu/gpu_countmin.cu.o gpu/device_memory.cu.o | ||
|
||
# web specific options | ||
web: CXX = em++ | ||
# optimised compile options | ||
# NB turn exceptions back on for testing | ||
# NB `--closure 1` can be used to reduce size of js file (this minifies variable names!) | ||
web: CXXFLAGS = -O3 -s ASSERTIONS=1 \ | ||
-DNOEXCEPT \ | ||
-DJSON_NOEXCEPTION \ | ||
-s DISABLE_EXCEPTION_CATCHING=1 \ | ||
-fno-exceptions \ | ||
-flto --bind -s STRICT=1 \ | ||
-s ALLOW_MEMORY_GROWTH=1 \ | ||
-s USE_ZLIB=1 \ | ||
-s MODULARIZE=1 \ | ||
-s "EXPORTED_FUNCTIONS=['_malloc']" \ | ||
-s 'EXPORTED_RUNTIME_METHODS=["FS"]' \ | ||
-s EXPORT_NAME=WebSketch \ | ||
-Wall -Wextra -std=c++14 | ||
web: CPPFLAGS += -DWEB_SKETCH | ||
web: LDFLAGS = -lnodefs.js -lworkerfs.js | ||
|
||
WEB_OUT=web/web_sketch | ||
WEB_OBJS=${WEB_OUT}.js ${WEB_OUT}.html ${WEB_OUT}.wasm | ||
|
||
web: web/web_sketch.o sketch/seqio.o sketch/sketch.o sketch/countmin.o | ||
$(LINK.cpp) $^ -o ${WEB_OUT}.js | ||
sed -i.old '1s;^;\/* eslint-disable *\/;' ${WEB_OUT}.js | ||
|
||
all: $(PROGRAMS) | ||
|
||
clean: | ||
$(RM) $(SKETCH_OBJS) $(GPU_SKETCH_OBJS) $(CUDA_OBJS) $(WEB_OBJS) *.o *.so version.h ~* $(PROGRAMS) | ||
|
||
install: all | ||
install -d $(BINDIR) | ||
install $(PROGRAMS) $(BINDIR) | ||
|
||
sketch_test: $(SKETCH_OBJS) test/main.o | ||
$(LINK.cpp) $(CUDA_LDFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS) | ||
|
||
matrix_test: $(SKETCH_OBJS) test/matrix_test.o | ||
$(LINK.cpp) $^ -o $@ $(LDLIBS) | ||
|
||
read_test: $(SKETCH_OBJS) $(GPU_SKETCH_OBJS) $(CUDA_OBJS) test/read_test.o | ||
nvcc $(CUDAFLAGS) $(CUDA_LDFLAGS) -Wno-deprecated-gpu-targets -shared -dlink $^ -o device_link.o -Xnvlink $(CUDA_LDLIBS) | ||
$(LINK.cpp) $(CUDA_LDFLAGS) $(LDFLAGS) $^ device_link.o -o $@ $(CUDA_LDLIBS) | ||
|
||
gpu_dist_test: $(SKETCH_OBJS) $(GPU_SKETCH_OBJS) $(CUDA_OBJS) test/gpu_dist_test.o | ||
nvcc $(CUDAFLAGS) $(CUDA_LDFLAGS) -Wno-deprecated-gpu-targets -shared -dlink $^ -o device_link.o -Xnvlink $(CUDA_LDLIBS) | ||
$(LINK.cpp) $(CUDA_LDFLAGS) $(LDFLAGS) $^ device_link.o -o $@ $(CUDA_LDLIBS) | ||
|
||
version.h: | ||
cat sketch/*.cpp sketch/*.hpp gpu/sketch.cu | openssl sha1 | awk '{print "#define SKETCH_VERSION \"" $$2 "\""}' > version.h | ||
|
||
database/database.o: version.h | ||
|
||
web/web_sketch.o: version.h | ||
|
||
python: $(PYTHON_LIB) | ||
|
||
$(PYTHON_LIB): $(SKETCH_OBJS) $(GPU_SKETCH_OBJS) $(CUDA_OBJS) sketchlib_bindings.o | ||
nvcc $(CUDAFLAGS) $(CUDA_LDFLAGS) -Wno-deprecated-gpu-targets -shared -dlink $^ -o device_link.o -Xnvlink $(CUDA_LDLIBS) | ||
$(LINK.cpp) $(CUDA_LDFLAGS) $(LDFLAGS) -shared $^ device_link.o -o $(PYTHON_LIB) $(CUDA_LDLIBS) | ||
|
||
install_python: python | ||
install -d $(PYTHON_LIB_PATH) | ||
install $(PYTHON_LIB) $(PYTHON_LIB_PATH) | ||
|
||
gpu/dist.cu.o: | ||
echo ${CUDAFLAGS} | ||
echo ${CPPFLAGS} | ||
echo ${CXXFLAGS} | ||
echo ${CFLAGS} | ||
nvcc $(CUDAFLAGS) $(CPPFLAGS) -DGPU_AVAILABLE -x cu -c gpu/dist.cu -o $@ | ||
|
||
gpu/sketch.cu.o: | ||
nvcc $(CUDAFLAGS) $(CPPFLAGS) -DGPU_AVAILABLE -x cu -c gpu/sketch.cu -o $@ | ||
|
||
gpu/device_memory.cu.o: | ||
nvcc $(CUDAFLAGS) $(CPPFLAGS) -DGPU_AVAILABLE -x cu -c gpu/device_memory.cu -o $@ | ||
|
||
gpu/device_reads.cu.o: | ||
nvcc $(CUDAFLAGS) $(CPPFLAGS) -DGPU_AVAILABLE -x cu -c gpu/device_reads.cu -o $@ | ||
|
||
gpu/gpu_countmin.cu.o: | ||
nvcc $(CUDAFLAGS) $(CPPFLAGS) -DGPU_AVAILABLE -x cu -c gpu/gpu_countmin.cu -o $@ | ||
|
||
.PHONY: all clean install python install_python web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.