Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
build/
build*
.vscode/
*output*/
videos/

48 changes: 48 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Building
This project uses CUDA, CMake 3.20+, and BLAS/LAPACK to compile.

To build CPU and GPU tests:
```
#Load CUDA and BLAS modules or libraries as needed
cmake -B build
cd build
make -j
```

To build with debug flags:
```
cmake -DCMAKE_BUILD_TYPE=Debug -B build_debug
#Proceed with build
```

To build with added GPU debugging :
```
cmake -DCMAKE_BUILD_TYPE=Debug -DCPPIMPACT_DEBUG_MODE=1 -B build_debug_gpu
#Proceed with build
```

## Running and Validating the Code

Running the `cpu_test` or `gpu_test` with the `--smoke` flag should run the first few steps of the algorithm (typically around 2000 updates).

Run the GPU test:
```
./gpu_test --smoke
Material: AL6061
ndof: 6162
Solving dynamics
Exported ../gpu_output/simulation_0.vtk
Elapsed time: 0.758019 seconds
```

You can change the input flag using `--input`.
```
./gpu_test --input "../input/fuselage 5086 elements.inp"
```

Using the validate.sh script, you can compare your result for any code changes to the "golden" output for a simple input file.

```
build]$ ../validation/validate.sh gpu_vel.txt ../validation/gpu_vel_smoke.txt
The files are identical.
```
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ endif()
find_package(LAPACK REQUIRED)

# Option for debug mode
# The global CPPIMPACT_DEBUG_MODE option applies to gpu_test
option(CPPIMPACT_DEBUG_MODE "Enable debug mode" OFF)
if(CPPIMPACT_DEBUG_MODE)
add_definitions(-DCPPIMPACT_DEBUG_MODE)
Expand Down Expand Up @@ -68,5 +69,23 @@ add_executable(gpu_test test.cu)
set_target_properties(gpu_test PROPERTIES CUDA_ARCHITECTURES ${GPU_ARCHS})
set_target_properties(gpu_test PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_compile_definitions(gpu_test PRIVATE -DCPPIMPACT_CUDA_BACKEND)
target_compile_options(gpu_test PRIVATE -G) # device debug
# The global CPPIMPACT_DEBUG_MODE option applies to gpu_test

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(gpu_test PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-G>)
#target_compile_options(gpu_test PRIVATE -G) # device debug
endif()

# Create output directories for visualization
set(CPU_DIRECTORY "${CMAKE_SOURCE_DIR}/cpu_output")
set(GPU_DIRECTORY "${CMAKE_SOURCE_DIR}/gpu_output")
if(NOT EXISTS ${CPU_DIRECTORY})
file(MAKE_DIRECTORY ${CPU_DIRECTORY})
file(MAKE_DIRECTORY ${GPU_DIRECTORY})
message(STATUS "Created directory: ${CPU_DIRECTORY}")
else()
message(STATUS "Directory already exists: ${CPU_DIRECTORY}")
endif()

#Copy over the validation folder
set(SOURCE_DIR "${CMAKE_SOURCE_DIR}/validation")
file(COPY ${SOURCE_DIR} DESTINATION ${CMAKE_BINARY_DIR})
Empty file added README.md
Empty file.
2 changes: 1 addition & 1 deletion include/dynamics.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class Dynamics {
cudaStreamSynchronize(streams[0]);
cudaStreamSynchronize(streams[1]);
cudaStreamSynchronize(streams[2]);
printf("Time: %f\n", time);
//printf("Time: %f\n", time);

update_dof<T>
<<<ndof_blocks, 32, 0, streams[0]>>>(ndof, dt, d_vel, d_global_dof);
Expand Down
15 changes: 13 additions & 2 deletions test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,32 @@ int main(int argc, char *argv[]) {
constexpr int dof_per_node = 3;

bool smoke_test = false;
std::string filename("../input/fuselage 5086 elements.inp");

if (argc > 1) {
if ("-h" == std::string(argv[1]) or "--help" == std::string(argv[1])) {
std::printf("Usage: ./gpu_test.cu [--smoke]\n");
std::printf("Usage: ./gpu_test.cu [--smoke] [--input <filename and params>]\n");
std::printf("Ex - run a short smoke test: ./gpu_test --smoke\n");
std::printf("Ex 2 - run a full test (0.5 simulation seconds): ./gpu_test --input \"../input/fuselage 5086 elements.inp\"\n");
std::printf("Ex 3 - run a larger test (NN simulation seconds): ./gpu_test --input \"../input/fuselage 603433 elements.inp\"\n");
std::printf("Ex 4 - run a larger test (NN simulation seconds): ./gpu_test --input \"../input/0.25 cube calculix linear 5758 elem.inp\"\n");
exit(0);
}

if ("--smoke" == std::string(argv[1])) {
smoke_test = true;
}

//Check for an input file
if ("--input" == std::string(argv[1])) {
filename=std::string(argv[2]);
}
}

std::vector<std::string> node_set_names;
// Load in the mesh
// std::string filename("../input/0.25 cube calculix linear 5758 elem.inp");
std::string filename("../input/fuselage 5086 elements.inp");
//std::string filename("../input/fuselage 5086 elements.inp");

Mesh<T, Basis::nodes_per_element> tensile;

Expand Down
Loading