Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,25 @@
# DEVICE=OCLGPU
# ------------------------------------------------------
# Choose OpenCL device
# Valid values: CPU, GPU, CUDA, OCLGPU
# Valid values: CPU, GPU, CUDA, OCLGPU, OPENCL

OVERLAP = ON

ifeq ($(DEVICE), $(filter $(DEVICE),GPU CUDA))
TEST_CUDA := $(shell ./test_cuda.sh nvcc "$(GPU_INCLUDE_PATH)" "$(GPU_LIBRARY_PATH)")
# if user specifies DEVICE=CUDA it will be used (wether the test succeeds or not)
TARGETS_SUPPORTED := $(shell ./test_cuda.sh nvcc "$(GPU_INCLUDE_PATH)" "$(GPU_LIBRARY_PATH)" "$(TARGETS)" "$(DEVICE)")
# if user specifies DEVICE=GPU the test result determines wether CUDA will be used or not
ifeq ($(DEVICE)$(TEST_CUDA),GPUyes)
ifeq ($(TARGETS_SUPPORTED),)
ifeq ($(DEVICE),CUDA)
$(error Cuda verification failed)
else
$(info Cuda is not available, using OpenCL)
$(info )
override DEVICE:=GPU
export
endif
else
override TARGETS:=$(TARGETS_SUPPORTED)
export
override DEVICE:=CUDA
endif
endif
Expand All @@ -37,9 +49,14 @@ override DEVICE:=GPU
export
include Makefile.Cuda
else
ifeq ($(DEVICE),OCLGPU)
ifeq ($(DEVICE),$(filter $(DEVICE),OCLGPU OPENCL))
override DEVICE:=GPU
export
$(info Using OpenCL)
$(info )
endif
$(info Please make sure to set environment variables)
$(info GPU_INCLUDE_PATH and GPU_LIBRARY_PATH)
$(info )
include Makefile.OpenCL
endif
4 changes: 2 additions & 2 deletions Makefile.Cuda
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ else
NWI=-DN16WI
TARGET:=$(TARGET)_16wi
else ifeq ($(DEVICE), GPU)
NWI=-DN64WI
TARGET:=$(TARGET)_64wi
NWI=-DN128WI
TARGET:=$(TARGET)_128wi
endif
endif

Expand Down
4 changes: 2 additions & 2 deletions Makefile.OpenCL
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ else
NWI=-DN16WI
TARGET:=$(TARGET)_16wi
else ifeq ($(DEVICE), GPU)
NWI=-DN64WI
TARGET:=$(TARGET)_64wi
NWI=-DN128WI
TARGET:=$(TARGET)_128wi
endif
endif

Expand Down
18 changes: 6 additions & 12 deletions host/src/getparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,8 @@ int parse_dpf(
if(mypars->ligandfile) free(mypars->ligandfile);
if(strincmp(argstr,"empty",5) != 0){
if(check_path && !has_absolute_path(argstr)){
len = strlen(argstr);
mypars->ligandfile = (char*)malloc((dpf_path.size()+len+1)*sizeof(char));
mypars->ligandfile[dpf_path.size()] = '\0'; // make sure first part to copy is terminated
strncat(strncpy(mypars->ligandfile, dpf_path.c_str(), dpf_path.size()), argstr, len);
mypars->ligandfile = (char*)malloc((dpf_path.size()+strlen(argstr)+1)*sizeof(char));
strcat(strcpy(mypars->ligandfile, dpf_path.c_str()), argstr);
} else mypars->ligandfile = strdup(argstr);
}
}
Expand All @@ -211,10 +209,8 @@ int parse_dpf(
sscanf(line.c_str(),"%*s %255s",argstr);
if(mypars->flexresfile) free(mypars->flexresfile);
if(check_path && !has_absolute_path(argstr)){
len = strlen(argstr);
mypars->flexresfile = (char*)malloc((dpf_path.size()+len+1)*sizeof(char));
mypars->flexresfile[dpf_path.size()] = '\0'; // make sure first part to copy is terminated
strncat(strncpy(mypars->flexresfile, dpf_path.c_str(), dpf_path.size()), argstr, len);
mypars->flexresfile = (char*)malloc((dpf_path.size()+strlen(argstr)+1)*sizeof(char));
strcat(strcpy(mypars->flexresfile, dpf_path.c_str()), argstr);
} else mypars->flexresfile = strdup(argstr);
}
break;
Expand All @@ -224,10 +220,8 @@ int parse_dpf(
// Add the .fld file
if(mypars->fldfile) free(mypars->fldfile);
if(check_path && !has_absolute_path(argstr)){
len = strlen(argstr);
mypars->fldfile = (char*)malloc((dpf_path.size()+len+1)*sizeof(char));
mypars->fldfile[dpf_path.size()] = '\0'; // make sure first part to copy is terminated
strncat(strncpy(mypars->fldfile, dpf_path.c_str(), dpf_path.size()), argstr, len);
mypars->fldfile = (char*)malloc((dpf_path.size()+strlen(argstr)+1)*sizeof(char));
strcat(strcpy(mypars->fldfile, dpf_path.c_str()), argstr);
} else mypars->fldfile = strdup(argstr); // this allows using the dpf to set up all parameters but the ligand
// Filling mygrid according to the specified fld file
if (get_gridinfo(mypars->fldfile, mygrid) != 0)
Expand Down
27 changes: 24 additions & 3 deletions test_cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,33 @@

current_dir=`pwd`
script_dir=`dirname $0`
CUDA_VERSION=`nvcc --version 2>/dev/null | grep release | awk '{ print $(NF-1) }' | sed "s/,//g"`
if [[ $CUDA_VERSION != "" ]]; then
printf "Using Cuda %s\n" $CUDA_VERSION >&2
else
if [[ $DEVICE == "CUDA" ]]; then
printf "Error: nvcc command does not exist/is not working properly.\n" >&2
fi
exit 1
fi
if [[ "$4" != "" ]]; then
for T in $4; do
TARGET_SUPPORTED=`nvcc --list-gpu-arch | grep $T`
if [[ $TARGET_SUPPORTED == "" ]]; then
printf "Error: Specified compute target <$T> not supported by installed Cuda version.\n" >&2
exit 1
fi
done
TARGETS="$4"
else
TARGETS=`nvcc --list-gpu-arch | awk -F'_' '{if(\$2>50) print \$2}' | tr "\n" " "`
fi
printf "Compiling for targets: %s\n" "$TARGETS" >&2
cd "$script_dir"
if [[ ! -f "test_cuda" ]]; then
$1 -I$2 -L$3 -lcuda -lcudart -o test_cuda test_cuda.cpp &> /dev/null
test -e test_cuda && echo yes || echo no
test -e test_cuda && echo $TARGETS
else
test -e test_cuda && echo yes || echo no
test -e test_cuda && echo $TARGETS
fi
cd "$current_dir"