diff --git a/src/Angle.h b/src/Angle.h index 4333de667c46639f3a97d500467c541297699053..a4e9542c0878b6b195092bfef5b3ea8a4633f1df 100644 --- a/src/Angle.h +++ b/src/Angle.h @@ -24,15 +24,15 @@ public: ind1(ind1), ind2(ind2), ind3(ind3), fileName(fileName), tabFileIndex(-1) { } int ind1, ind2, ind3; + String fileName; // tabFileIndex will be assigned after ComputeForce loads the // TabulatedAnglePotentials. The tabefileIndex is used by ComputeForce to // discern which TabulatedAnglePotential this Angle uses. int tabFileIndex; - String fileName; inline Angle(const Angle& a) : ind1(a.ind1), ind2(a.ind2), ind3(a.ind3), - tabFileIndex(a.tabFileIndex), - fileName(a.fileName) { } + fileName(a.fileName), + tabFileIndex(a.tabFileIndex) { } HOST DEVICE inline float calcAngle(Vector3* pos, BaseGrid* sys) { const Vector3& posa = pos[ind1]; diff --git a/src/ComputeForce.cu b/src/ComputeForce.cu index dd4ed64f31a7ecbc1a84de0acf8aec1f923afae8..580a73496e52be0476e250f0c097ec318a2bc3e6 100644 --- a/src/ComputeForce.cu +++ b/src/ComputeForce.cu @@ -71,6 +71,8 @@ ComputeForce::ComputeForce(int num, const BrownianParticleType part[], // Create the bond table tableBond = new TabulatedPotential*[numTabBondFiles]; tableBond_addr = new TabulatedPotential*[numTabBondFiles]; + bondList_d = NULL; + tableBond_d = NULL; for (int i = 0; i < numTabBondFiles; i++) { tableBond_addr[i] = NULL; tableBond[i] = NULL; @@ -80,6 +82,8 @@ ComputeForce::ComputeForce(int num, const BrownianParticleType part[], // Create the angle table tableAngle = new TabulatedAnglePotential*[numTabAngleFiles]; tableAngle_addr = new TabulatedAnglePotential*[numTabAngleFiles]; + angleList_d = NULL; + tableAngle_d = NULL; for (int i = 0; i < numTabAngleFiles; i++) { tableAngle_addr[i] = NULL; tableAngle[i] = NULL; @@ -89,6 +93,8 @@ ComputeForce::ComputeForce(int num, const BrownianParticleType part[], // Create the dihedral table tableDihedral = new TabulatedDihedralPotential*[numTabDihedralFiles]; tableDihedral_addr = new TabulatedDihedralPotential*[numTabDihedralFiles]; + dihedralList_d = NULL; + tableDihedral_d = NULL; for (int i = 0; i < numTabDihedralFiles; i++) { tableDihedral_addr[i] = NULL; tableDihedral[i] = NULL; @@ -149,13 +155,24 @@ ComputeForce::~ComputeForce() { gpuErrchk( cudaFree(pos_d) ); gpuErrchk( cudaFree(forceInternal_d) ); gpuErrchk( cudaFree(type_d) ); - gpuErrchk( cudaFree(bonds_d) ); - gpuErrchk( cudaFree(bondMap_d) ); - gpuErrchk( cudaFree(excludes_d) ); - gpuErrchk( cudaFree(excludeMap_d) ); - gpuErrchk( cudaFree(angles_d) ); - gpuErrchk( cudaFree(dihedrals_d) ); - gpuErrchk( cudaFree(bondList_d) ); + if (numBonds > 0) { + gpuErrchk( cudaFree(bonds_d) ); + gpuErrchk( cudaFree(bondMap_d) ); + gpuErrchk( cudaFree(bondList_d) ); + } + if (numAngles > 0) { + gpuErrchk( cudaFree(angles_d) ); + gpuErrchk( cudaFree(angleList_d) ); + } + if (numDihedrals > 0) { + gpuErrchk( cudaFree(dihedrals_d) ); + gpuErrchk( cudaFree(dihedralList_d) ); + gpuErrchk( cudaFree(dihedralPotList_d) ); + } + if (numExcludes > 0) { + gpuErrchk( cudaFree(excludes_d) ); + gpuErrchk( cudaFree(excludeMap_d) ); + } } gpuErrchk(cudaFree(numPairs_d)); diff --git a/src/DcdWriter.h b/src/DcdWriter.h index d5ab57d2933eab11315383df196c82edbb094865..50904e021fb9074000070f042fbb17f8f618e4ac 100644 --- a/src/DcdWriter.h +++ b/src/DcdWriter.h @@ -287,7 +287,8 @@ public: /* Unit cell */ if (cell) { - out_integer = 48; + // out_integer = 48; + out_integer = 6*4; // this seems correct for float NAMD_write(fd, (char *) &out_integer, sizeof(int)); NAMD_write(fd, (char *) cell, out_integer); NAMD_write(fd, (char *) &out_integer, sizeof(int)); diff --git a/src/GrandBrownTown.cu b/src/GrandBrownTown.cu index 5cc934bee06c78cd7b38b5fe11834928d985fec4..bc776402cf64b11ef27e70250614e1e508df3d3e 100644 --- a/src/GrandBrownTown.cu +++ b/src/GrandBrownTown.cu @@ -302,9 +302,17 @@ GrandBrownTown::~GrandBrownTown() { delete[] pos; delete[] type; delete[] serial; - delete[] bondList; delete randoGen; + if (numBonds > 0) + delete[] bondList; + if (numAngles > 0) + delete[] angleList; + if (numDihedrals > 0) { + delete[] dihedralList; + delete[] dihedralPotList; + } + // Auxillary objects delete internal; for (int i = 0; i < numReplicas; ++i) @@ -1041,9 +1049,9 @@ void GrandBrownTown::copyToCUDA() { cudaMemcpyHostToDevice));*/ gpuErrchk(cudaMalloc(&randoGen_d, sizeof(Random))); - gpuErrchk(cudaMemcpyAsync(randoGen_d, randoGen, sizeof(Random), + gpuErrchk(cudaMemcpy(randoGen_d, randoGen, sizeof(Random), cudaMemcpyHostToDevice)); - gpuErrchk(cudaDeviceSynchronize()); + // gpuErrchk(cudaDeviceSynchronize()); } /*void GrandBrownTown::createBondList() diff --git a/src/Makefile b/src/Makefile index f359fd0962d8ba25d45f90877c3ea21a3f07c510..b58905be1702555a4e8dacb1080f8abc32c594ae 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,15 +3,14 @@ include ./findcudalib.mk INCLUDE = $(CUDA_PATH)/include ifeq ($(dbg),1) - CC_FLAGS += -g -O0 NV_FLAGS += -g -G - EX_FLAGS = -O0 -m$(OS_SIZE) + EX_FLAGS = -g -O0 -m$(OS_SIZE) else EX_FLAGS = -O3 -m$(OS_SIZE) endif CC_FLAGS += -I$(CUDA_PATH)/include -# CC_FLAGS += -Wall -Wno-write-strings -std=c++0x -pedantic +CC_FLAGS += -Wall -Wno-write-strings -std=c++0x -pedantic # TODO: test on Mac OSX NV_FLAGS += -lineinfo ifneq ($(DARWIN),) diff --git a/src/arbd.cpp b/src/arbd.cpp index 32bcccda9a257765acd9933fda17b33774b783fd..78ae60cb43105678eaabed93309bd7c4e011959b 100644 --- a/src/arbd.cpp +++ b/src/arbd.cpp @@ -31,13 +31,12 @@ int main(int argc, char* argv[]) { return 0; } else if (argc == 2 && (strcmp(argv[1], "--version") == 0)) { // --version - printf("%s 0.1a\n", argv[0]); - printf("Written by Jeff Comer, Justin Dufresne, and Terrance Howard.\n"); + printf("%s Nov 2016 (alpha)\n", argv[0]); return 0; } else if (argc == 2 && (strcmp(argv[1], "--info") == 0)) { // --info GPUManager::load_info(); - size_t n_gpus = max(GPUManager::gpus.size(), 1lu); + // size_t n_gpus = max(GPUManager::gpus.size(), 1lu); return 0; } else if (argc < 3) { printf("%s: missing arguments\n", argv[0]); @@ -50,7 +49,7 @@ int main(int argc, char* argv[]) { bool debug = false, safe = true; int replicas = 1; - unsigned int imd_port; + unsigned int imd_port = 0; bool imd_on = false; int num_flags = 0; for (int pos = 1; pos < argc; pos++) { @@ -66,7 +65,7 @@ int main(int argc, char* argv[]) { num_flags++; } else if (strcmp(arg, "-g") == 0 || strcmp(arg, "--gpu") == 0) { - int arg_val = atoi(argv[pos + 1]); + unsigned int arg_val = atoi(argv[pos + 1]); gpuID = arg_val; num_flags += 2; if (arg_val < 0 || arg_val > n_gpus) { diff --git a/src/findcudalib.mk b/src/findcudalib.mk index 4694c946b5466539734bf91bfd21628b12079b26..7f4c10c89b10f502c17e95ebc9f5205820e76109 100644 --- a/src/findcudalib.mk +++ b/src/findcudalib.mk @@ -36,7 +36,7 @@ ## Find Location of most recent CUDA Toolkit ifeq (,$(CUDA_PATH)) - CUDA_PATH := $(shell echo $(wildcard /usr/local/cuda*) | tail -n1) + CUDA_PATH := $(shell echo $(wildcard /usr/local/cuda*) | tr ' ' '\n' | tail -n1) ifeq (,$(CUDA_PATH)) $(error Could not CUDA_PATH. Please pass as follows: $(MAKE) CUDA_PATH=/path/to/cuda) endif diff --git a/src/useful.h b/src/useful.h index 1618b9a463b4132658ea1a2a5fffc49591e63daf..25d2951e7e296b1e33a12b91f11e5a5cd9bdca97 100644 --- a/src/useful.h +++ b/src/useful.h @@ -267,9 +267,9 @@ public: HOST DEVICE inline Matrix3() {} HOST DEVICE Matrix3(float s); HOST DEVICE Matrix3(float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz); - Matrix3(float x, float y, float z); - Matrix3(const Vector3& ex, const Vector3& ey, const Vector3& ez); - Matrix3(const float* d); + HOST DEVICE Matrix3(float x, float y, float z); + HOST DEVICE Matrix3(const Vector3& ex, const Vector3& ey, const Vector3& ez); + HOST DEVICE Matrix3(const float* d); // Operators