Skip to content
Snippets Groups Projects
Commit f82dd72c authored by cmaffeo2's avatar cmaffeo2
Browse files

Improved build scripts

parent 0bc64470
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*~ *~
.backup .backup
TAGS TAGS
TAGS.sh
.dir-locals.el .dir-locals.el
BD_example* BD_example*
runBrownCUDA arbd
runBrownCUDA
\ No newline at end of file
...@@ -666,7 +666,7 @@ public: ...@@ -666,7 +666,7 @@ public:
// Wrap coordinate: 0 <= x < l // Wrap coordinate: 0 <= x < l
HOST DEVICE inline int quotient(float x, float l) const { HOST DEVICE inline int quotient(float x, float l) const {
#ifdef __CUDA_ARCH__ #if __CUDA_ARCH__ > 0
return int(floorf( __fdividef(x,l) )); return int(floorf( __fdividef(x,l) ));
#else #else
return int(floor(x/l)); return int(floor(x/l));
......
### Paths, libraries, includes, options ### Paths, libraries, includes, options
include ./findcudalib.mk include ./findcudalib.mk
CUDA_PATH ?= /usr/local/cuda-8.0
$(info CUDA_PATH=$(CUDA_PATH))
INCLUDE = $(CUDA_PATH)/include INCLUDE = $(CUDA_PATH)/include
NV_FLAGS += v
ifeq ($(dbg),1) ifeq ($(dbg),1)
DEBUG = -g -O0 CC_FLAGS += -g -O0
NV_FLAGS = -v -g -G NV_FLAGS += -g -G
EX_FLAGS = -O0 -m$(OS_SIZE) EX_FLAGS = -O0 -m$(OS_SIZE)
else else
NV_FLAGS = -v
EX_FLAGS = -O3 -m$(OS_SIZE) EX_FLAGS = -O3 -m$(OS_SIZE)
endif endif
CC_FLAGS = -Wall -Wno-write-strings -I$(INCLUDE) $(DEBUG) -std=c++0x -pedantic CC_FLAGS += -Wall -Wno-write-strings -I$(INCLUDE) -std=c++0x -pedantic
NV_FLAGS += -lineinfo NV_FLAGS += -lineinfo
ifneq ($(MAVERICKS),)
CC = $(CLANG)
CC_FLAGS += -stdlib=libstdc++
NV_FLAGS += -Xcompiler -arch -Xcompiler x86_64
else
CC = $(GCC)
endif
ifneq ($(DARWIN),) ifneq ($(DARWIN),)
LIBRARY = $(CUDA_PATH)/lib LIBRARY = $(CUDA_PATH)/lib
else else
...@@ -33,13 +22,17 @@ endif ...@@ -33,13 +22,17 @@ endif
# NV_FLAGS += -ftz=true # TODO: test if this preserves accurate simulation # NV_FLAGS += -ftz=true # TODO: test if this preserves accurate simulation
## Find valid compute capabilities for this machine
SMS ?= 20 30 35 37 50 52 60 SMS ?= 20 30 35 37 50 52 60
## Generate SASS code $(info Testing CUDA toolkit with compute capabilities SMS='$(SMS)')
$(foreach SM,$(SMS), $(eval NV_FLAGS += -gencode arch=compute_$(SM),code=sm_$(SM)) ) SMS := $(shell for sm in $(SMS); do $(NVCC) cuda-test.c -arch=sm_$$sm &> /dev/null && echo $$sm; done)
SMPTXS ?= $(lastword $(sort $(SMS)))
$(info Building SASS code for SMS='$(SMS)' and PTX code for '$(SMPTXS)')
## Generate PTX code for highest SM architecture for future GPUs ## Generate SASS and PTX code
SM=$(lastword $(sort $(SMS))) $(foreach SM,$(SMS), $(eval NV_FLAGS += -gencode arch=compute_$(SM),code=sm_$(SM)) )
NV_FLAGS += -gencode arch=compute_$(SM),code=sm_$(SM) $(foreach SM,$(SMPTXS), $(eval NV_FLAGS += -gencode arch=compute_$(SM),code=compute_$(SM)) )
NVLD_FLAGS := $(NV_FLAGS) --device-link NVLD_FLAGS := $(NV_FLAGS) --device-link
LD_FLAGS = -L$(LIBRARY) -lcurand -lcudart -lcudadevrt -Wl,-rpath,$(LIBRARY) LD_FLAGS = -L$(LIBRARY) -lcurand -lcudart -lcudadevrt -Wl,-rpath,$(LIBRARY)
...@@ -52,7 +45,6 @@ CU_SRC := $(wildcard *.cu) ...@@ -52,7 +45,6 @@ CU_SRC := $(wildcard *.cu)
CC_OBJ := $(patsubst %.cpp, %.o, $(CC_SRC)) CC_OBJ := $(patsubst %.cpp, %.o, $(CC_SRC))
CU_OBJ := $(patsubst %.cu, %.o, $(CU_SRC)) CU_OBJ := $(patsubst %.cu, %.o, $(CU_SRC))
### Targets ### Targets
TARGET = arbd TARGET = arbd
......
#include <assert.h>
#include "Configuration.h" #include "Configuration.h"
#include "RigidBodyType.h" #include "RigidBodyType.h"
#include "Reservoir.h" #include "Reservoir.h"
#include "BaseGrid.h" #include "BaseGrid.h"
#include "RigidBodyGrid.h" #include "RigidBodyGrid.h"
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) {
if (code != cudaSuccess) { if (code != cudaSuccess) {
......
#! /bin/bash
# etags *.h* *.c*
etags -l c++ *.[cChH]*
#include <cuda_runtime.h>
int main(int argc, char **argv) {}
...@@ -34,6 +34,17 @@ ...@@ -34,6 +34,17 @@
# #
################################################################################ ################################################################################
## Find Location of most recent CUDA Toolkit
ifeq (,$(CUDA_PATH))
CUDA_PATH := $(shell echo $(wildcard /usr/local/cuda*) | tr ' ' '\n' | sort -Vr | head -n1)
ifeq (,$(CUDA_PATH))
$(info ERROR: Could not CUDA_PATH. Please pass as follows: $(MAKE) CUDA_PATH=/path/to/cuda)
exit
else
$(info Using CUDA_PATH=$(CUDA_PATH))
endif
endif
# OS Name (Linux or Darwin) # OS Name (Linux or Darwin)
OSUPPER = $(shell uname -s 2>/dev/null | tr "[:lower:]" "[:upper:]") OSUPPER = $(shell uname -s 2>/dev/null | tr "[:lower:]" "[:upper:]")
OSLOWER = $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]") OSLOWER = $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
...@@ -66,6 +77,7 @@ ifneq ($(DARWIN),) ...@@ -66,6 +77,7 @@ ifneq ($(DARWIN),)
LION = $(strip $(findstring 10.7, $(shell egrep "<string>10\.7" /System/Library/CoreServices/SystemVersion.plist))) LION = $(strip $(findstring 10.7, $(shell egrep "<string>10\.7" /System/Library/CoreServices/SystemVersion.plist)))
MOUNTAIN = $(strip $(findstring 10.8, $(shell egrep "<string>10\.8" /System/Library/CoreServices/SystemVersion.plist))) MOUNTAIN = $(strip $(findstring 10.8, $(shell egrep "<string>10\.8" /System/Library/CoreServices/SystemVersion.plist)))
MAVERICKS = $(strip $(findstring 10.9, $(shell egrep "<string>10\.9" /System/Library/CoreServices/SystemVersion.plist))) MAVERICKS = $(strip $(findstring 10.9, $(shell egrep "<string>10\.9" /System/Library/CoreServices/SystemVersion.plist)))
MAVERICKS = $(strip $(findstring 10.9, $(shell egrep "<string>10\.9" /System/Library/CoreServices/SystemVersion.plist)))
endif endif
# Common binaries # Common binaries
...@@ -73,16 +85,16 @@ GCC ?= g++ ...@@ -73,16 +85,16 @@ GCC ?= g++
CLANG ?= /usr/bin/clang++ CLANG ?= /usr/bin/clang++
ifeq ("$(OSUPPER)","LINUX") ifeq ("$(OSUPPER)","LINUX")
NVCC ?= $(CUDA_PATH)/bin/nvcc -ccbin $(GCC) CC=$(GCC)
else else
# for some newer versions of XCode, CLANG is the default compiler, so we need to include this # for some newer versions of XCode, CLANG is the default compiler, so we need to include this
ifneq ($(MAVERICKS),) ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
NVCC ?= $(CUDA_PATH)/bin/nvcc -ccbin $(CLANG) CC = $(CLANG)
STDLIB ?= -stdlib=libstdc++ CC_FLAGS += -stdlib=libstdc++
else NV_FLAGS += -Xcompiler -arch -Xcompiler x86_64
NVCC ?= $(CUDA_PATH)/bin/nvcc -ccbin $(GCC) endif
endif
endif endif
NVCC ?= $(CUDA_PATH)/bin/nvcc -ccbin $(CC)
# Take command line flags that override any of these settings # Take command line flags that override any of these settings
ifeq ($(i386),1) ifeq ($(i386),1)
...@@ -97,130 +109,3 @@ ifeq ($(ARMv7),1) ...@@ -97,130 +109,3 @@ ifeq ($(ARMv7),1)
OS_SIZE = 32 OS_SIZE = 32
OS_ARCH = armv7l OS_ARCH = armv7l
endif endif
ifeq ("$(OSUPPER)","LINUX")
# Each Linux Distribuion has a set of different paths. This applies especially when using the Linux RPM/debian packages
ifeq ("$(DISTRO)","ubuntu")
CUDAPATH ?= /usr/lib/nvidia-current
CUDALINK ?= -L/usr/lib/nvidia-current
DFLT_PATH = /usr/lib
endif
ifeq ("$(DISTRO)","kubuntu")
CUDAPATH ?= /usr/lib/nvidia-current
CUDALINK ?= -L/usr/lib/nvidia-current
DFLT_PATH = /usr/lib
endif
ifeq ("$(DISTRO)","debian")
CUDAPATH ?= /usr/lib/nvidia-current
CUDALINK ?= -L/usr/lib/nvidia-current
DFLT_PATH = /usr/lib
endif
ifeq ("$(DISTRO)","suse")
ifeq ($(OS_SIZE),64)
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib64
else
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib
endif
endif
ifeq ("$(DISTRO)","suse linux")
ifeq ($(OS_SIZE),64)
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib64
else
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib
endif
endif
ifeq ("$(DISTRO)","opensuse")
ifeq ($(OS_SIZE),64)
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib64
else
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib
endif
endif
ifeq ("$(DISTRO)","fedora")
ifeq ($(OS_SIZE),64)
CUDAPATH ?= /usr/lib64/nvidia
CUDALINK ?= -L/usr/lib64/nvidia
DFLT_PATH = /usr/lib64
else
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib
endif
endif
ifeq ("$(DISTRO)","redhat")
ifeq ($(OS_SIZE),64)
CUDAPATH ?= /usr/lib64/nvidia
CUDALINK ?= -L/usr/lib64/nvidia
DFLT_PATH = /usr/lib64
else
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib
endif
endif
ifeq ("$(DISTRO)","red")
ifeq ($(OS_SIZE),64)
CUDAPATH ?= /usr/lib64/nvidia
CUDALINK ?= -L/usr/lib64/nvidia
DFLT_PATH = /usr/lib64
else
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib
endif
endif
ifeq ("$(DISTRO)","redhatenterpriseworkstation")
ifeq ($(OS_SIZE),64)
CUDAPATH ?= /usr/lib64/nvidia
CUDALINK ?= -L/usr/lib64/nvidia
DFLT_PATH ?= /usr/lib64
else
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH ?= /usr/lib
endif
endif
ifeq ("$(DISTRO)","centos")
ifeq ($(OS_SIZE),64)
CUDAPATH ?= /usr/lib64/nvidia
CUDALINK ?= -L/usr/lib64/nvidia
DFLT_PATH = /usr/lib64
else
CUDAPATH ?=
CUDALINK ?=
DFLT_PATH = /usr/lib
endif
endif
ifeq ($(ARMv7),1)
CUDAPATH := /usr/arm-linux-gnueabihf/lib
CUDALINK := -L/usr/arm-linux-gnueabihf/lib
ifneq ($(TARGET_FS),)
CUDAPATH += $(TARGET_FS)/usr/lib/nvidia-current
CUDALINK += -L$(TARGET_FS)/usr/lib/nvidia-current
endif
endif
# Search for Linux distribution path for libcuda.so
CUDALIB ?= $(shell find $(CUDAPATH) $(DFLT_PATH) -name libcuda.so -print 2>/dev/null)
ifeq ("$(CUDALIB)",'')
$(info >>> WARNING - CUDA Driver libcuda.so is not found. Please check and re-install the NVIDIA driver. <<<)
EXEC=@echo "[@]"
endif
else
# This would be the Mac OS X path if we had to do anything special
endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment