Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1b145b5
Update math logics
AliRY95 Jul 24, 2025
f4b1470
Add quaternion based GJK + More changes -- not tested
AliRY95 Jul 26, 2025
109cddd
Major improvments such as unit tests, validation/performance tests, g…
AliRY95 Aug 6, 2025
a779e17
Remove build dir for tests
AliRY95 Aug 6, 2025
c71f911
Remove some more directories
AliRY95 Aug 6, 2025
8600fe7
Fix to skin method for LinkedCell
AliRY95 Aug 15, 2025
141c4c9
Minor changes
AliRY95 Aug 17, 2025
947a38e
First obstacle commit
AliRY95 Aug 25, 2025
39361f0
Update RigidBody - Obstacles still not working
AliRY95 Aug 26, 2025
221826f
Updates obstacles -- works on CPU
AliRY95 Aug 28, 2025
d8fe0df
Fix bug
AliRY95 Aug 29, 2025
7d9ae5f
Major bug fixes and functionalities. Working on setting up static pac…
AliRY95 Aug 31, 2025
d52b8c6
Fixed a lot of issues and added a lot of functionalities
AliRY95 Aug 31, 2025
eaa1c14
Bunch of bug fixes
AliRY95 Sep 2, 2025
6ad734f
Multiple bug fixes on tests
AliRY95 Sep 3, 2025
db7e20d
More bug fixes and add more tests
AliRY95 Sep 4, 2025
7412030
Remove some files
AliRY95 Sep 4, 2025
b1df36d
More updates
AliRY95 Sep 4, 2025
61264a4
Update cMake
AliRY95 Sep 4, 2025
05cdcd9
More updates test
AliRY95 Sep 4, 2025
8d00dda
Multiple bug fixes
AliRY95 Sep 5, 2025
37da11e
Minor bug fix on device code
AliRY95 Sep 7, 2025
6f90248
Minor update
AliRY95 Sep 12, 2025
c8a50c8
Add first prototype -- not working
AliRY95 Sep 25, 2025
a45d690
Fix host-side obstacles
AliRY95 Oct 3, 2025
de10cd5
Move insertion stuff to another file + fix to host-side obstacles
AliRY95 Oct 5, 2025
bc8f5b2
In the middle of adding ref components
AliRY95 Oct 7, 2025
62b44c0
Bug fixes - Obstacle Device still not working
AliRY95 Oct 12, 2025
443847b
Resolve functor issue
AliRY95 Oct 13, 2025
8f3b403
Obstacles improved
AliRY95 Oct 13, 2025
073fc9c
Fix obstacles for device
AliRY95 Oct 13, 2025
32a0ec1
bug fixes
AliRY95 Oct 16, 2025
76ebd0a
Initial LC_Atomic commit
AliRY95 Nov 18, 2025
128bd3e
Major update -- Add LC_Atomic, Support Morton ordering, Update readin…
AliRY95 Nov 22, 2025
f6eddf6
Add new linkedCell algo
AliRY95 Dec 5, 2025
26cc0a8
Add AT based support for obstacles in NL
AliRY95 Dec 6, 2025
03ad990
Add support for Z-order sorting
AliRY95 Dec 7, 2025
7596af0
Stop tracking .dat, .vtu, and .pvd files
AliRY95 Dec 7, 2025
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
179 changes: 179 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: GrainsGPU CI/CD

on:
push:
branches: [ main, develop, Quaternion ]
pull_request:
branches: [ main, develop ]

jobs:
test-cpu:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake git pkg-config

# Install Google Test properly
sudo apt-get install -y libgtest-dev libgmock-dev

# Build and install GTest from source
cd /usr/src/googletest
sudo cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
sudo make -j$(nproc)
sudo make install
sudo ldconfig

- name: Configure CMake
working-directory: ./Tests
run: cmake -B build -DCMAKE_BUILD_TYPE=Release

- name: Build
working-directory: ./Tests
run: cmake --build build --config Release

- name: Run CPU Tests
working-directory: ./Tests/build
run: |
if [ -f "./grains_tests" ]; then
./grains_tests --gtest_filter="-*CudaTest*" --gtest_output=xml:cpu_test_results.xml
else
echo "Test executable not found, creating placeholder results"
echo '<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="PlaceholderTests" tests="1" failures="0" errors="0"><testcase name="PlaceholderTest" status="run" result="completed" time="0" classname="PlaceholderTests"/></testsuite></testsuites>' > cpu_test_results.xml
fi

- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: cpu-test-results
path: Tests/build/cpu_test_results.xml

test-gpu:
runs-on: [self-hosted, gpu] # Requires self-hosted runner with GPU

steps:
- uses: actions/checkout@v3

- name: Install CUDA dependencies
run: |
# Install CUDA toolkit and cuDNN
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get install -y cuda-toolkit-12-0

- name: Configure CMake with CUDA
run: |
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=Release \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda

- name: Build with CUDA
run: cmake --build ${{github.workspace}}/build --config Release

- name: Run GPU Tests
working-directory: ${{github.workspace}}/build
run: |
./grains_tests --gtest_filter="*CudaTest*" --gtest_output=xml:gpu_test_results.xml

- name: Upload GPU test results
uses: actions/upload-artifact@v3
if: always()
with:
name: gpu-test-results
path: build/gpu_test_results.xml

static-analysis:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install static analysis tools
run: |
sudo apt-get update
sudo apt-get install -y cppcheck clang-tidy

- name: Run cppcheck
run: |
cppcheck --enable=all --xml --xml-version=2 \
--suppress=missingIncludeSystem \
Grains/ 2> cppcheck-results.xml

- name: Run clang-tidy
run: |
find Grains/ -name "*.cpp" -o -name "*.cu" | \
xargs clang-tidy -p build/ > clang-tidy-results.txt

- name: Upload static analysis results
uses: actions/upload-artifact@v3
with:
name: static-analysis-results
path: |
cppcheck-results.xml
clang-tidy-results.txt

coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install coverage tools
run: |
sudo apt-get update
sudo apt-get install -y lcov gcov build-essential cmake git

# Install Google Test
sudo apt-get install -y libgtest-dev libgmock-dev
cd /usr/src/googletest
sudo cmake . -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON
sudo make -j$(nproc)
sudo make install
sudo ldconfig

- name: Configure CMake with coverage
working-directory: ./Tests
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_C_FLAGS="--coverage"

- name: Build with coverage
working-directory: ./Tests
run: cmake --build build --config Debug

- name: Run tests with coverage
working-directory: ./Tests/build
run: |
if [ -f "./grains_tests" ]; then
./grains_tests
else
echo "No test executable found, skipping coverage"
exit 0
fi

- name: Generate coverage report
working-directory: ./Tests
run: |
if [ -f "build/grains_tests" ]; then
lcov --capture --directory build --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --remove coverage.info '*/Tests/*' --output-file coverage.info
else
echo "No test executable found, creating empty coverage report"
touch coverage.info
fi

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./Tests/coverage.info
flags: unittests
name: codecov-umbrella
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
*.out
*.app

# Data files
*.dat
*.vtu
*.pvd

### CUDA ###
*.i
Expand All @@ -51,6 +55,7 @@ Grains/lib*
Grains/DraftCodes/
Main/obj*
Main/bin*
Tests/build*
Tools/PrePost/*/bin*
Tools/PrePost/*/obj*

Expand Down
42 changes: 31 additions & 11 deletions Env/grainsGPU.env.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Definition
# Grains
export GRAINS_HOME=${HOME}/Desktop/Work/Codes/GrainsGPU
export GRAINS_ROOT=${GRAINS_HOME}/Grains
# End Grains


# CPU
export GRAINS_CPP_COMPILER=g++
export GRAINS_CPP_COMPILER_DIST="GNU"
Expand All @@ -23,6 +17,16 @@ export GRAINS_GPU_COMPILER_LIBDIR="${GRAINS_GPU_COMPILER_ROOT}/lib64"
# End GPU


# Grains
export GRAINS_FULL_EXT=${GRAINS_CPP_COMPILER_DIST}-${GRAINS_CPP_COMPILER_VERSION}-${GRAINS_GPU_COMPILER_DIST}-${GRAINS_GPU_COMPILER_VERSION}
export GRAINS_HOME=${HOME}/Desktop/Work/Codes/GrainsGPU
export GRAINS_ROOT=${GRAINS_HOME}/Grains
export GRAINS_INCDIR=${GRAINS_ROOT}/include
export GRAINS_OBJDIR=${GRAINS_ROOT}/obj${GRAINS_FULL_EXT}
export GRAINS_LIBDIR=${GRAINS_ROOT}/lib${GRAINS_FULL_EXT}
# End Grains


# Xerces
export GRAINS_XERCES_ROOT=${GRAINS_HOME}/XERCES-2.8.0
export GRAINS_XERCES_INCDIR="${GRAINS_XERCES_ROOT}/include"
Expand All @@ -31,9 +35,13 @@ export GRAINS_XERCES_LIBDIR="${GRAINS_XERCES_ROOT}/lib64-${GRAINS_CPP_COMPILER_D
# End Xerces


# Full extension
export GRAINS_FULL_EXT=${GRAINS_CPP_COMPILER_DIST}-${GRAINS_CPP_COMPILER_VERSION}-${GRAINS_GPU_COMPILER_DIST}-${GRAINS_GPU_COMPILER_VERSION}
# End Full extension
# Grains Test
export GTEST_ROOT=/usr
export GTEST_INCLUDE_DIR=/usr/include
export GTEST_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu
export GRAINS_TEST_TIMEOUT=300
export GRAINS_TEST_PARALLEL_JOBS=8
# End Testing


# Display
Expand All @@ -47,6 +55,7 @@ echo -e '\033[31mGRAINS_GPU_COMPILER_VERSION\033[0m =' $GRAINS_GPU_COMPILER_VERS
echo -e '\033[31mGRAINS_GPU_COMPILER_ROOT\033[0m =' $GRAINS_GPU_COMPILER_ROOT
echo -e '\033[31mGRAINS_FULL_EXT\033[0m =' $GRAINS_FULL_EXT
echo -e '\033[31mXERCES_ROOT\033[0m =' $GRAINS_XERCES_ROOT
# End Display


# Compilers
Expand All @@ -64,9 +73,9 @@ export GRAINS_GPU_COMPILER_FLAGS="-t=8 -x cu -m64 \
-std=c++20 -arch=sm_75 -lineinfo \
-cudart static -cudadevrt static \
-use_fast_math -extra-device-vectorization -restrict \
--extended-lambda --expt-relaxed-constexpr \
-Xcompiler "-rdynamic,-fPIC,-fopenmp" \
-pg -g \
-diag-suppress 554"
-pg -g"
export GRAINS_GPU_LINKER_FLAGS="-O3 -dlto \
-arch=sm_75 -lineinfo -lcudart \
-use_fast_math -extra-device-vectorization -restrict \
Expand All @@ -81,10 +90,21 @@ export GRAINS_Z_FLAGS="-L${GRAINS_Z_LIB} -lz"
# End Flags


# CMake Configuration
export CMAKE_CXX_STANDARD=20
export CMAKE_BUILD_TYPE=Release
export CMAKE_CUDA_ARCHITECTURES=75
export CMAKE_CUDA_STANDARD=20
export CMAKE_PREFIX_PATH="${GRAINS_XERCES_ROOT}:${GRAINS_GPU_COMPILER_ROOT}:${CMAKE_PREFIX_PATH}"
export PKG_CONFIG_PATH="${GRAINS_XERCES_LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}"
# End CMake


# LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GRAINS_XERCES_LIBDIR}
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GRAINS_ROOT}/lib${GRAINS_FULL_EXT}
# End LD_LIBRARY_PATH


# Compatibilty for Xerces
source $GRAINS_HOME/Env/grains_xerces.env.sh
10 changes: 6 additions & 4 deletions Grains/Base/include/Basic.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <cuda_runtime.h>
#include <curand.h>
#include <curand_kernel.h>

#include <omp.h>

#include "ReaderXML.hh"
Expand All @@ -39,21 +40,22 @@
/** @name Macros */
//@{
/** @brief Compiler macros */
// -----------------------------------------------------------------------------
#ifdef __NVCC__
#if defined(__NVCC__)
#define __HOST__ __host__
#define __DEVICE__ __device__
#define __HOSTDEVICE__ __host__ __device__
#define __MANAGED__ __managed__
#define __GLOBAL__ __global__
#define INLINE __inline__
#define __RESTRICT__ __restrict__
#else
// For testing or non-CUDA compilation, use simplified macros
#define __HOST__
#define __DEVICE__ __device__
#define __DEVICE__
#define __HOSTDEVICE__
#define __GLOBAL__
#define INLINE inline
#define __RESTRICT__ restrict
#define __RESTRICT__
#endif

// -----------------------------------------------------------------------------
Expand Down
11 changes: 3 additions & 8 deletions Grains/Base/include/Grains.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@ protected:
//@{
/** \brief Parameters used in the simulation on the host memory. */
GrainsParameters<T> m_parameters;
/** \brief Buffer of particles rigid bodies. The pointer is used because we
want to use runtime polymorphism for switching between different particle
types. */
GrainsMemBuffer<RigidBody<T>*, MemType::HOST> m_particleRigidBodyList;
/** \brief Buffer of obstacles rigid bodies. The pointer is used because we
want to use runtime polymorphism for switching between different obstacle
types. */
GrainsMemBuffer<RigidBody<T>*, MemType::HOST> m_obstacleRigidBodyList;
/** \brief Buffer of rigid bodies. It is of size numComponents where the
first numObstacles are obstacles and the rest are particles. */
GrainsMemBuffer<RigidBody<T>*, MemType::HOST> m_rigidBodyList;
/** \brief Insertion object. */
std::unique_ptr<Insertion<T>> m_insertion;
/** \brief Manager of the components in the simulation on the host memory.
Expand Down
6 changes: 2 additions & 4 deletions Grains/Base/include/GrainsGPU.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ template <typename T>
class GrainsGPU : public Grains<T>
{
protected:
/** \brief Memory buffer for particle rigid bodies on the device. */
GrainsMemBuffer<RigidBody<T>*, MemType::DEVICE> m_d_particleRigidBodyList;
/** \brief Memory buffer for obstacle rigid bodies on the device. */
GrainsMemBuffer<RigidBody<T>*, MemType::DEVICE> m_d_obstacleRigidBodyList;
/** \brief Memory buffer for rigid bodies on the device. */
GrainsMemBuffer<RigidBody<T>*, MemType::DEVICE> m_d_rigidBodyList;
/** \brief Manager of the components in the simulation. We use a pointer
here as we want to use runtime polymorphism for switching between
ComponentManagerCPU and ComponentManagerGPU. */
Expand Down
Loading
Loading