-
Notifications
You must be signed in to change notification settings - Fork 5
Work #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HannoSpreeuw
wants to merge
28
commits into
treecode:master
Choose a base branch
from
LourensVeen:work
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Work #12
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
ef3093f
Fix build for newer CUDA and conda-installed dependencies
LourensVeen 194bead
Redo build system
LourensVeen 18342fc
Make tests compile with the new build system and conda
LourensVeen ad2b2f2
Avoid clash with EasyBuild CUDA INCLUDEPATH variable
LourensVeen a7134e7
Keep the .ptx files, they're actually the ones that get used
LourensVeen cafc823
Fix symlinking error on repeated builds
LourensVeen ecabda6
Improve README a bit
LourensVeen 5fde0ac
Fix error when building for newer GPU architectures
LourensVeen 3347293
Add .gitignore for the test directory
LourensVeen 9d9ea58
Replace old build system with new build system
LourensVeen 54cae9f
Update build instructions in the README
LourensVeen feeb564
Make dependency of interfaces on libsapporo explicit
LourensVeen b3d4951
Enable make clean even if there's no CUDA or OpenGL available
LourensVeen 674292c
Include kernels also when compiling with CUDA
LourensVeen 19ac0b9
Make .gitignore only match the executables, not the source in the subdir
LourensVeen 12e8f13
Also update the OpenCL test makefile
LourensVeen 1bd149e
Rearrange directory structure
LourensVeen cc92791
Rename license file so that GitHub will pick it up
LourensVeen 6c3f8fb
Add public API headers for G6 and 6th order
LourensVeen 644c727
Add make install target
LourensVeen d4ff577
Improve CUDA builds
LourensVeen 0730f7a
Add initial Conda build definition
LourensVeen 6064eb5
Use CXX environment variable in OpenCL detection
LourensVeen 6ef3114
Fix conda OpenCL dependencies
LourensVeen b615d28
Add build number to the conda build string
LourensVeen 025dea9
Fix conda dso whitelist
LourensVeen 512c2dd
Fix kernel names after directory rearrangement
LourensVeen 0476d61
Fix OpenCL test link and clean up small things
LourensVeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| *.o | ||
| *.a | ||
| *.so | ||
| *~ | ||
| *.ptx | ||
| *.ptxh | ||
| *.cle | ||
| *.clh |
File renamed without changes.
This file contains hidden or 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,213 @@ | ||
| CXX ?= g++ | ||
| CC ?= gcc | ||
| PREFIX ?= /usr/local | ||
|
|
||
|
|
||
| .PHONY: all | ||
| all: libsapporo.a libsapporo.so emulated_interfaces | ||
|
|
||
|
|
||
| # Detect CUDA | ||
| ifndef CUDA_TK | ||
| NVCC := $(shell which nvcc || echo NOTFOUND) | ||
| ifeq ($(NVCC), NOTFOUND) | ||
| $(info The nvcc command is not available in your shell.) | ||
| $(info To compile with CUDA, please install it, set up your environment) | ||
| $(info according to the CUDA installation instructions, and try again.) | ||
| $(info ) | ||
| else | ||
| CUDA_TK := $(dir $(NVCC)).. | ||
| CUDA_AVAILABLE := 1 | ||
| endif | ||
| else | ||
| NVCC ?= $(CUDA_TK)/bin/nvcc | ||
| CUDA_AVAILABLE := 1 | ||
| endif | ||
|
|
||
|
|
||
| # Detect OpenCL | ||
| OPENCL_LDFLAGS := -lOpenCL | ||
| ifdef OPENCL | ||
| OPENCL_LDFLAGS := -L$(OPENCL)/lib -lOpenCL | ||
| endif | ||
|
|
||
| OPENCL_STATUS := $(shell echo 'int main() {}' | $(CXX) -x c++ $(OPENCL_LDFLAGS) - && rm a.out || echo NOTFOUND) | ||
|
|
||
| ifeq ($(OPENCL_STATUS), NOTFOUND) | ||
| $(info OpenCL support was not detected on the system.) | ||
| $(info If it is installed in a non-standard location, then set OPENCL to) | ||
| $(info the installation prefix and try again.) | ||
| $(info ) | ||
| else | ||
| OPENCL_AVAILABLE := 1 | ||
| endif | ||
|
|
||
|
|
||
| # Select backend | ||
| ifeq ($(filter clean,$(MAKECMDGOALS)),) | ||
| ifndef BACKEND | ||
| ifdef CUDA_AVAILABLE | ||
| $(info BACKEND not set and CUDA was detected, using CUDA) | ||
| BACKEND := CUDA | ||
| else | ||
| ifdef OPENCL_AVAILABLE | ||
| $(info BACKEND not set and OpenCL was detected, using OpenCL) | ||
| BACKEND := OpenCL | ||
| else | ||
| $(error BACKEND not set and neither CUDA nor OpenGL was detected.) | ||
| endif | ||
| endif | ||
| else | ||
| ifeq ($(BACKEND), CUDA) | ||
| ifndef CUDA_AVAILABLE | ||
| $(error BACKEND set to CUDA but it was not found.) | ||
| endif | ||
| $(info Using selected backend CUDA) | ||
| else | ||
| ifeq ($(BACKEND), OpenCL) | ||
| ifndef OPENCL_AVAILABLE | ||
| $(error BACKEND set to OpenCL but it was not found.) | ||
| endif | ||
| else | ||
| $(error BACKEND set to unknown value "$(BACKEND)", please use CUDA or OpenCL) | ||
| endif | ||
| $(info Using selected backend OpenCL) | ||
| endif | ||
| endif | ||
| endif | ||
| $(info ) | ||
|
|
||
| # Testing/optimisation support | ||
| ifdef NTHREADS | ||
| CXXFLAGS += -DNTHREADS=$(NTHREADS) -DTIMING_STATS=1 | ||
| endif | ||
|
|
||
| ifdef NBLOCKS_PER_MULTI | ||
| CXXFLAGS += -DNBLOCKS_PER_MULTI=$(NBLOCKS_PER_MULTI) -DTIMING_STATS=1 | ||
| endif | ||
|
|
||
|
|
||
| # CUDA kernels | ||
| ifeq ($(BACKEND), CUDA) | ||
|
|
||
| INCLUDES = -I$(CUDA_TK) | ||
| CXXFLAGS += -D__INCLUDE_KERNELS__ | ||
| LDFLAGS += -lcuda -fopenmp | ||
|
|
||
| CUDA_SRC = $(wildcard src/CUDA/*.cu) | ||
| PTX = $(CUDA_SRC:src/CUDA/%.cu=src/CUDA/%.ptx) | ||
| PTXH = $(CUDA_SRC:src/CUDA/%.cu=src/CUDA/%.ptxh) | ||
| NVCCFLAGS += -Isrc | ||
|
|
||
| KERNELS = $(PTX) $(PTXH) | ||
|
|
||
| %.ptx: %.cu | ||
| $(NVCC) --forward-unknown-to-host-compiler $(CXXFLAGS) $(NVCCFLAGS) -ptx $< -o $@ | ||
|
|
||
| src/CUDA/%.ptxh: src/CUDA/%.ptx | ||
| xxd -i $< $@ | ||
|
|
||
| endif | ||
|
|
||
|
|
||
| # OpenCL kernels | ||
| ifeq ($(BACKEND), OpenCL) | ||
|
|
||
| ifdef OPENCL | ||
| CXXFLAGS += -I$(OPENCL)/include | ||
| LDFLAGS += -L$(OPENCL)/lib | ||
| endif | ||
|
|
||
| INCLUDES = | ||
| CXXFLAGS += -D_OCL_ -D__INCLUDE_KERNELS__ | ||
| LDFLAGS += -lOpenCL -fopenmp | ||
|
|
||
| OPENCL_SRC = $(wildcard src/OpenCL/*.cl) | ||
| CLE = $(OPENCL_SRC:src/OpenCL/%.cl=src/OpenCL/%.cle) | ||
| CLH = $(OPENCL_SRC:src/OpenCL/%.cl=src/OpenCL/%.clh) | ||
|
|
||
| KERNELS = $(CLE) $(CLH) | ||
|
|
||
| %.cle: %.cl | ||
| $(CC) -E -Isrc -o $@ - <$< | ||
|
|
||
| # xxd names the variable after the file name argument, and we expect | ||
| # the variable to not have a src_ prefix, so we have to remove it. | ||
| src/OpenCL/%.clh: src/OpenCL/%.cle | ||
| cd src && xxd -i $(<:src/%=%) $(@:src/%=%) | ||
|
|
||
| endif | ||
|
|
||
|
|
||
| # Main implementation | ||
| CXX_SRC := $(wildcard src/*.cpp src/SSE_AVX/*.cpp) | ||
| OBJS := $(CXX_SRC:%.cpp=%.o) | ||
| INCLUDES += -Isrc | ||
| CXXFLAGS += $(INCLUDES) -fPIC -g -O3 -Wall -Wextra -Wstrict-aliasing=2 -fopenmp | ||
|
|
||
| src/sapporohostclass.o: $(KERNELS) | ||
|
|
||
| %.o: %.cpp | ||
| $(CXX) $(CXXFLAGS) -c $< -o $@ | ||
|
|
||
| libsapporo.a: $(OBJS) | ||
| ar qv $@ $^ | ||
|
|
||
| libsapporo.so: $(OBJS) | ||
| $(CXX) -o $@ -shared $^ $(LDFLAGS) | ||
|
|
||
|
|
||
| # API compatibility libraries | ||
| EMU_SRC := $(wildcard src/interfaces/*lib.cpp) | ||
| EMU_STATIC_LIBS := $(EMU_SRC:src/interfaces/%lib.cpp=lib%.a) | ||
| EMU_SHARED_LIBS := $(EMU_SRC:src/interfaces/%lib.cpp=lib%.so) | ||
|
|
||
| .PHONY: emulated_interfaces | ||
| emulated_interfaces: $(EMU_STATIC_LIBS) $(EMU_SHARED_LIBS) | ||
|
|
||
| $(EMU_STATIC_LIBS): libsapporo.a | ||
|
|
||
| $(EMU_SHARED_LIBS): libsapporo.so | ||
|
|
||
|
|
||
| lib%.a: src/interfaces/%lib.o | ||
| ar qv $@ $^ | ||
|
|
||
| lib%.so: src/interfaces/%lib.o | ||
| $(CXX) -o $@ -shared $^ -L. -lsapporo $(LDFLAGS) | ||
|
|
||
|
|
||
| # Installation | ||
| INSTALLED_LIBS := $(PREFIX)/lib/libsapporo.a $(PREFIX)/lib/libsapporo.so | ||
| INSTALLED_LIBS += $(EMU_STATIC_LIBS:%.a=$(PREFIX)/lib/%.a) | ||
| INSTALLED_LIBS += $(EMU_SHARED_LIBS:%.so=$(PREFIX)/lib/%.so) | ||
|
|
||
| INSTALLED_LIBS: $(PREFIX)/lib | ||
|
|
||
| HEADERS := $(wildcard include/*) | ||
| INSTALLED_HEADERS := $(HEADERS:include/%=$(PREFIX)/include/%) | ||
|
|
||
| INSTALLED_HEADERS: $(PREFIX)/include | ||
|
|
||
| $(PREFIX)/include: | ||
| mkdir -p $(PREFIX)/include | ||
|
|
||
| $(PREFIX)/include/%: include/% $(PREFIX)/include | ||
| install -m 644 $< $@ | ||
|
|
||
| $(PREFIX)/lib: | ||
| mkdir -p $(PREFIX)/lib | ||
|
|
||
| $(PREFIX)/lib/%: % $(PREFIX)/lib | ||
| install -m 644 $< $@ | ||
|
|
||
| .PHONY: install | ||
| install: $(INSTALLED_LIBS) $(INSTALLED_HEADERS) | ||
|
|
||
|
|
||
| # Clean-up | ||
| .PHONY: clean | ||
| clean: | ||
| rm -f *.a *.so src/*.o src/SSE_AVX/SSE/*.o src/SSE_AVX/AVX/*.o | ||
| rm -f src/CUDA/*.ptx src/CUDA/*.ptxh src/OpenCL/*.cle src/OpenCL/*.clh | ||
|
|
This file contains hidden or 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 hidden or 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,4 @@ | ||
| gpu_backend: | ||
| - cuda | ||
| - opencl | ||
|
|
This file contains hidden or 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,52 @@ | ||
| {% set name = "sapporo2" %} | ||
| {% set version = "0.0.1" %} | ||
|
|
||
| package: | ||
| name: {{ name|lower }} | ||
| version: {{ version }} | ||
|
|
||
| source: | ||
| path: ../ | ||
| # git_rev: work | ||
| # git_url: https://github.com/LourensVeen/sapporo2.git | ||
|
|
||
| build: | ||
| number: 0 | ||
| string: {{ gpu_backend }}_{{ PKG_BUILDNUM }} | ||
|
|
||
| script_env: | ||
| - BACKEND=CUDA # [gpu_backend == 'cuda'] | ||
| - BACKEND=OpenCL # [gpu_backend == 'opencl'] | ||
| script: make install | ||
|
|
||
| missing_dso_whitelist: | ||
| - "*/libcuda.so*" | ||
|
|
||
| requirements: | ||
| build: | ||
| - {{ compiler('cxx') }} | ||
| - git | ||
| - git-lfs | ||
| - make | ||
| - cuda-compiler # [linux and gpu_backend == 'cuda'] | ||
| - pocl # [linux and gpu_backend == 'opencl'] | ||
| - vim | ||
| # - conda-verify | ||
|
|
||
| host: | ||
| - ocl-icd # [linux and gpu_backend == 'opencl'] | ||
|
|
||
| run: | ||
| - cuda-runtime # [linux and gpu_backend == 'cuda'] | ||
| - libgcc-ng | ||
| - libstdcxx-ng | ||
| - _openmp_mutex | ||
|
|
||
| test: | ||
|
|
||
| about: | ||
| home: https://github.com/treecode/sapporo2 | ||
| summary: Library for emulating GRAPE6 n-body calculations | ||
| license: GPL-3.0-only | ||
| license_family: GPL | ||
| license_file: LICENSE |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand setting a path like
or better
but the extra
makeI do not understand.