Skip to content

Commit 9b9f611

Browse files
authored
Merge pull request #1881 from CEED/SirAlienTheGreat/rust-qfunctions
Rust and cuda clang support (#1873)
2 parents 1ad4660 + f03c7ee commit 9b9f611

File tree

26 files changed

+1206
-76
lines changed

26 files changed

+1206
-76
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ doc/sphinx/build/
5151
# Example docs automatically copied from source tree
5252
doc/sphinx/source/examples/
5353

54+
# Clang GPU temp files
55+
temp/*
56+
5457
# Output files, videos, and compressed archives should not be added accidentally
5558
*.avi
5659
*.bin

.gitlab-ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,61 @@ noether-cpu:
171171
# - touch .SUCCESS
172172

173173

174+
# ----------------------------------------------------------------------------------------
175+
# Rust + CUDA
176+
# ----------------------------------------------------------------------------------------
177+
noether-rust-qfunctions:
178+
stage: test:gpu-and-float
179+
tags:
180+
- cuda
181+
interruptible: true
182+
before_script:
183+
# Environment
184+
- export COVERAGE=1 CC=gcc CXX=g++ FC=gfortran NVCC=nvcc GPU_CLANG=1
185+
- export NPROC_POOL=1
186+
- echo "-------------- nproc ---------------" && NPROC_CPU=$(nproc) && NPROC_GPU=$(($(nproc)<8?$(nproc):8)) && echo "NPROC_CPU" $NPROC_CPU && echo "NPROC_GPU" $NPROC_GPU
187+
- echo "-------------- CC ------------------" && $CC --version
188+
- echo "-------------- CXX -----------------" && $CXX --version
189+
- echo "-------------- FC ------------------" && $FC --version
190+
- echo "-------------- NVCC ----------------" && $NVCC --version
191+
- echo "-------------- Rustc ---------------" && rustc --version
192+
- echo "-------------- Clang++ -------------" && clang++ --version
193+
- echo "-------------- GCOV ----------------" && gcov --version
194+
script:
195+
- rm -f .SUCCESS
196+
# Rustup
197+
- rustup update nightly
198+
- rustup component add rust-src --toolchain nightly
199+
- rustup component add llvm-tools --toolchain nightly
200+
# libCEED
201+
- make configure OPT='-O -march=native -ffp-contract=fast' CUDA_DIR=/usr/local/cuda-12.9
202+
- echo "-------------- libCEED -------------" && make info
203+
- make clean
204+
- make -k -j$NPROC_CPU -l$NPROC_CPU
205+
# -- libCEED only tests
206+
- echo "-------------- Rust QFunction tests -----"
207+
# Note: PETSC_DIR is set by default in GitLab runner env, unsetting to isolate core tests
208+
- export PETSC_DIR= PETSC_ARCH=
209+
- make -k -j$((NPROC_GPU / NPROC_POOL)) JUNIT_BATCH="rust-qfunction" junit search=rustqfunction
210+
# Report status
211+
- touch .SUCCESS
212+
after_script:
213+
- |
214+
if [ -f .SUCCESS ]; then
215+
lcov --directory . --capture --output-file coverage.info --ignore-errors source,mismatch;
216+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F interface;
217+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F gallery;
218+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F backends;
219+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F tests;
220+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F examples;
221+
fi
222+
artifacts:
223+
paths:
224+
- build/*.junit
225+
reports:
226+
junit: build/*.junit
227+
228+
174229
# ----------------------------------------------------------------------------------------
175230
# CUDA backends
176231
# ----------------------------------------------------------------------------------------

Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[workspace]
22
members = [
3-
"rust/libceed",
4-
"rust/libceed-sys",
5-
"examples/rust/ex1-volume",
6-
"examples/rust/ex1-volume-vector",
7-
"examples/rust/ex2-surface",
8-
"examples/rust/ex2-surface-vector",
9-
"examples/rust/ex3-volume",
10-
"examples/rust/ex3-volume-vector",
11-
"examples/rust/mesh",
3+
"rust/libceed",
4+
"rust/libceed-sys",
5+
"examples/rust/ex1-volume",
6+
"examples/rust/ex1-volume-vector",
7+
"examples/rust/ex2-surface",
8+
"examples/rust/ex2-surface-vector",
9+
"examples/rust/ex3-volume",
10+
"examples/rust/ex3-volume-vector",
11+
"examples/rust/mesh",
1212
]
13+
exclude = ["examples/rust-qfunctions/ex1-volume-rs"]

Makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ mfemexamples := $(mfemexamples.cpp:examples/mfem/%.cpp=$(OBJDIR)/mfem-%)
349349
# Nek5K Examples
350350
nekexamples := $(OBJDIR)/nek-bps
351351

352+
# Rust QFunction Examples
353+
rustqfunctions.c := $(sort $(wildcard examples/rust-qfunctions/*.c))
354+
rustqfunctionsexamples := $(rustqfunctions.c:examples/rust-qfunctions/%.c=$(OBJDIR)/rustqfunctions-%)
355+
352356
# PETSc Examples
353357
petscexamples.c := $(wildcard examples/petsc/*.c)
354358
petscexamples := $(petscexamples.c:examples/petsc/%.c=$(OBJDIR)/petsc-%)
@@ -733,6 +737,11 @@ $(OBJDIR)/nek-bps : examples/nek/bps/bps.usr examples/nek/nek-examples.sh $(libc
733737
mv examples/nek/build/bps $(OBJDIR)/bps
734738
cp examples/nek/nek-examples.sh $(OBJDIR)/nek-bps
735739

740+
# Rust QFunctions
741+
$(OBJDIR)/rustqfunctions-% : examples/rust-qfunctions/%.c $(libceed) | $$(@D)/.DIR
742+
+$(MAKE) -C examples/rust-qfunctions CEED_DIR=`pwd`
743+
cp examples/rust-qfunctions/$* $@
744+
736745
# PETSc
737746
# Several executables have common utilities, but we can't build the utilities
738747
# from separate submake invocations because they'll compete with each
@@ -763,19 +772,22 @@ $(OBJDIR)/solids-% : examples/solids/%.c examples/solids/%.h \
763772
PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $*
764773
cp examples/solids/$* $@
765774

766-
examples : $(allexamples)
767-
ceedexamples : $(examples)
768-
nekexamples : $(nekexamples)
769-
mfemexamples : $(mfemexamples)
775+
examples : $(allexamples)
776+
ceedexamples : $(examples)
777+
nekexamples : $(nekexamples)
778+
mfemexamples : $(mfemexamples)
770779
petscexamples : $(petscexamples)
771780

781+
rustqfunctionsexamples : $(rustqfunctionsexamples)
782+
772783
external_examples := \
773784
$(if $(MFEM_DIR),$(mfemexamples)) \
774785
$(if $(PETSC_DIR),$(petscexamples)) \
775786
$(if $(NEK5K_DIR),$(nekexamples)) \
776787
$(if $(DEAL_II_DIR),$(dealiiexamples)) \
777788
$(if $(PETSC_DIR),$(fluidsexamples)) \
778-
$(if $(PETSC_DIR),$(solidsexamples))
789+
$(if $(PETSC_DIR),$(solidsexamples)) \
790+
$(if $(or $(RUST_QF),$(GPU_CLANG)),$(rustqfunctionsexamples))
779791

780792
allexamples = $(examples) $(external_examples)
781793

@@ -904,6 +916,7 @@ cln clean :
904916
$(call quiet,MAKE) -C examples clean NEK5K_DIR="$(abspath $(NEK5K_DIR))"
905917
$(call quiet,MAKE) -C python/tests clean
906918
$(RM) benchmarks/*output.txt
919+
$(RM) -rf temp
907920

908921
distclean : clean
909922
$(RM) -r doc/html doc/sphinx/build $(CONFIG)

backends/cuda/ceed-cuda-common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ static const char *cublasGetErrorName(cublasStatus_t error) {
6666

6767
typedef struct {
6868
int device_id;
69+
bool use_llvm_version;
70+
int llvm_version;
6971
cublasHandle_t cublas_handle;
7072
struct cudaDeviceProp device_prop;
7173
} Ceed_Cuda;

0 commit comments

Comments
 (0)