cpu_backend.cpp - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
HTML git clone git://src.adamsgaard.dk/sphere
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
cpu_backend.cpp (1216B)
---
1 // cpu_backend.cpp -- CPU-backend replacement for utility.cu plus the
2 // definitions of the CUDA execution-model emulation globals.
3 #include <iostream>
4 #include <omp.h>
5
6 #include "cpu_backend.h"
7 #include "sphere.h"
8
9 thread_local uint3 threadIdx;
10 thread_local uint3 blockIdx;
11 dim3 blockDim;
12 dim3 gridDim;
13
14 void DEM::diagnostics()
15 {
16 // Retrieve information from device to host and run diagnostic tests
17 transferFromGlobalDeviceMemory();
18 checkValues();
19
20 // Clean up memory before exiting
21 if (fluid == 1 && cfd_solver == 0) {
22 freeNSmemDev();
23 freeNSmem();
24 }
25 if (fluid == 1 && cfd_solver == 1) {
26 freeDarcyMemDev();
27 freeDarcyMem();
28 }
29 freeGlobalDeviceMemory();
30 // CPU memory freed upon object destruction
31 }
32
33 // The CPU shims cannot fail asynchronously, so the checks are no-ops
34 void DEM::checkForCudaErrors(const char*, const int) {}
35
36 void DEM::checkForCudaErrorsIter(const char*, const unsigned int, const int) {}
37
38 void DEM::initializeGPU()
39 {
40 ndevices = 1;
41 if (verbose == 1)
42 std::cout << " CPU backend (OpenMP), max threads: "
43 << omp_get_max_threads() << std::endl;
44 }
45 // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4