tdo not generate separate binary for porous flow, add exclusive mode flag - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 7310210eeea7eaea39afad0b6642866a417ef323
(DIR) parent 7e9994c85ea1f10fc5040bb9d7d628bc5b4cc133
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Mon, 28 Jul 2014 09:58:07 +0200
do not generate separate binary for porous flow, add exclusive mode flag
Diffstat:
M python/sphere.py | 4 ++--
M src/CMakeLists.txt | 2 --
M src/device.cu | 11 ++++++-----
M src/main.cpp | 13 +++++++++++--
D src/porousflow.cpp | 83 -------------------------------
M src/sphere.cpp | 15 ++++++++-------
M src/sphere.h | 4 +++-
7 files changed, 30 insertions(+), 102 deletions(-)
---
(DIR) diff --git a/python/sphere.py b/python/sphere.py
t@@ -3103,10 +3103,10 @@ class sim:
if (cudamemcheck == True):
cudamemchk = "cuda-memcheck --leak-check full "
if (self.fluid == True):
- binary = "porousflow"
+ fluidarg = "--fluid "
cmd = "cd ..; " + valgrindbin + cudamemchk + "./" + binary + " " \
- + quiet + dryarg + "input/" + self.sid + ".bin " + stdout
+ + quiet + dryarg + fluidarg + "input/" + self.sid + ".bin " + stdout
#print(cmd)
status = subprocess.call(cmd, shell=True)
(DIR) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
t@@ -30,8 +30,6 @@ CUDA_ADD_EXECUTABLE(../porosity
CUDA_ADD_EXECUTABLE(../forcechains
forcechains.cpp file_io.cpp sphere.cpp device.cu utility.cu utility.cpp
navierstokes.cpp)
-CUDA_ADD_EXECUTABLE(../porousflow
- porousflow.cpp navierstokes.cpp file_io.cpp sphere.cpp device.cu utility.cpp utility.cu)
#ADD_EXECUTABLE(unittests boost-unit-tests.cpp sphere.cpp)
#TARGET_LINK_LIBRARIES(unittests
(DIR) diff --git a/src/device.cu b/src/device.cu
t@@ -109,12 +109,13 @@ __host__ void DEM::initializeGPU(void)
}
device = cudadevice; // store in DEM class
- cout << " Using CUDA device ID " << cudadevice << " with "
- << max_ncudacores << " cores." << std::endl;
- // Comment following line when using a system only containing
- // exclusive mode GPUs
- cudaChooseDevice(&cudadevice, &prop);
+ // Only call cudaChooseDevice if the exlusive mode flag isn't set
+ if (exclusive_mode != 1) {
+ cout << " Using CUDA device ID " << cudadevice << " with "
+ << max_ncudacores << " cores." << std::endl;
+ cudaChooseDevice(&cudadevice, &prop);
+ }
checkForCudaErrors("While initializing CUDA device");
}
(DIR) diff --git a/src/main.cpp b/src/main.cpp
t@@ -36,6 +36,8 @@ int main(const int argc, const char *argv[])
int nfiles = 0; // number of input files
float max_val = 0.0f; // max value of colorbar
float lower_cutoff = 0.0f;// lower cutoff, particles below won't be rendered
+ int fluid = 0;
+ int exclusive_mode = 0; // system GPUs are running on exclusive mode
// Process input parameters
int i;
t@@ -54,6 +56,7 @@ int main(const int argc, const char *argv[])
"-e, --exclusive\t\tset this flag for systems containing\n"
" \t\tonly exclusive-mode GPUs\n"
"-n, --dry\t\tshow key experiment parameters and quit\n"
+ "-f, --fluid\t\tsimulate fluid between particles\n"
"-r, --render\t\trender input files to images instead of\n"
" \t\tsimulating the temporal evolution\n"
"-dc, --dont-check\tdon't check values before running\n"
t@@ -101,6 +104,12 @@ int main(const int argc, const char *argv[])
else if (argvi == "-dc" || argvi == "--dont-check")
checkVals = 0;
+ else if (argvi == "-f" || argvi == "--fluid")
+ fluid = 1;
+
+ else if (argvi == "-e" || argvi == "--exclusive")
+ exlusive_mode = 1;
+
else if (argvi == "-m" || argvi == "--method") {
render = 1;
t@@ -153,7 +162,7 @@ int main(const int argc, const char *argv[])
// Create DEM class, read data from input binary, check values,
// init cuda, transfer const mem
- DEM dem(argvi, verbose, checkVals, dry, 1, 1);
+ DEM dem(argvi, verbose, checkVals, dry, 1, 1, fluid, exclusive_mode);
// Render image if requested
if (render == 1)
dem.render(method, max_val, lower_cutoff);
t@@ -165,7 +174,7 @@ int main(const int argc, const char *argv[])
} else {
// Do not transfer to const. mem after the first file
- DEM dem(argvi, verbose, checkVals, dry, 1, 0);
+ DEM dem(argvi, verbose, checkVals, dry, 1, 0, fluid, exclusive_mode);
// Render image if requested
if (render == 1)
(DIR) diff --git a/src/porousflow.cpp b/src/porousflow.cpp
t@@ -1,83 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/* SPHERE source code by Anders Damsgaard Christensen, 2010-12, */
-/* a 3D Discrete Element Method algorithm with CUDA GPU acceleration. */
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-// Licence: GNU Public License (GPL) v. 3. See license.txt.
-// See doc/sphere-doc.pdf for full documentation.
-// Compile with GNU make by typing 'make' in the src/ directory.
-// SPHERE is called from the command line with './sphere_<architecture> projectname'
-
-
-// Including library files
-#include <iostream>
-#include <string>
-#include <cstdlib>
-
-// Including user files
-#include "constants.h"
-#include "datatypes.h"
-#include "sphere.h"
-
-//////////////////
-// MAIN ROUTINE //
-//////////////////
-// The main loop returns the value 0 to the shell, if the program terminated
-// successfully, and 1 if an error occured which caused the program to crash.
-int main(const int argc, const char *argv[])
-{
- // Default values
- int verbose = 1;
- int dry = 0;
- int nfiles = 0;
- int darcy = 1;
-
- // Process input parameters
- int i;
- for (i=1; i<argc; ++i) { // skip argv[0]
-
- std::string argvi = std::string(argv[i]);
-
- // Display help if requested
- if (argvi == "-h" || argvi == "--help") {
- std::cout << argv[0] << ": particle dynamics simulator\n"
- << "Usage: " << argv[0] << " [OPTION[S]]... [FILE1 ...]\nOptions:\n"
- << "-h, --help\t\tprint help\n"
- << "-n, --dry\t\tshow key experiment parameters and quit\n"
- << std::endl;
- return 0; // Exit with success
- }
-
- else if (argvi == "-n" || argvi == "--dry")
- dry = 1;
-
- else if (argvi == "-q" || argvi == "--quiet")
- verbose = 0;
-
- // The rest of the values must be input binary files
- else {
- nfiles++;
-
- if (verbose == 1)
- std::cout << argv[0] << ": processing input file: " << argvi <<
- std::endl;
-
- // Create DEM class, read data from input binary,
- // check values, init cuda, transfer const mem, solve Darcy flow
- DEM dem(argvi, verbose, 1, dry, 1, 1, darcy);
- if (dry == 0)
- dem.startTime();
- }
- }
-
- // Check whether there are input files specified
- if (!argv[0] || argc == 1 || nfiles == 0) {
- std::cerr << argv[0] << ": missing input binary file\n"
- << "See `" << argv[0] << " --help` for more information"
- << std::endl;
- return 1; // Return unsuccessful exit status
- }
-
- return 0; // Return successfull exit status
-}
-// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
(DIR) diff --git a/src/sphere.cpp b/src/sphere.cpp
t@@ -14,13 +14,14 @@
// Constructor: Reads an input binary, and optionally checks
// and reports the values
DEM::DEM(const std::string inputbin,
- const int verbosity,
- const int checkVals,
- const int dry,
- const int initCuda,
- const int transferConstMem,
- const int porousflow)
-: verbose(verbosity), navierstokes(porousflow)
+ const int verbosity,
+ const int checkVals,
+ const int dry,
+ const int initCuda,
+ const int transferConstMem,
+ const int fluidFlow,
+ const int exlusive)
+: verbose(verbosity), navierstokes(fluidFlow), exlusive_mode(exlusive)
{
using std::cout;
using std::cerr;
(DIR) diff --git a/src/sphere.h b/src/sphere.h
t@@ -57,6 +57,7 @@ class DEM {
int ndevices; // number of CUDA GPUs
int device; // primary GPU
int* domain_size; // elements per GPU
+ int exlusive_mode; // devices are running in exclusive mode (1)
// DEVICE ARRAYS
t@@ -296,7 +297,8 @@ class DEM {
const int dry = 0,
const int initCuda = 1,
const int transferConstMem = 1,
- const int darcyflow = 0);
+ const int fluidFlow = 0,
+ const int exclusive = 0);
// Destructor
~DEM(void);