Skip to content

Commit 2027fb9

Browse files
SirAlienTheGreatAllen MacFarland
authored andcommitted
Rust and cuda clang support (#1873)
* Switch compiler to clang (not portable) * test add_num * compile with llvm tools * not working linking * not fixed * Update ex1-volume.h * update * remove global path * changes * changes 2 * crate works * basic gpu rust compilation * still not working * rust source roots basic support * nvrtc/clang selection * cleanup * update example (not working) * add rust example * fix merge issue * delete temp files * cleanup * rust qfunc 2d array (needs doc) * cleanup * more cleanup * downgrade back to c++11 * format * final draft cleanup * formatting + CUDA_CLANG -> GPU_CLANG * Update cuda CEED_QFUNCTION_RUST * fix python * fix python and format * format fr * update comment * fix python fr * Apply error suggestions from code review * update errors to libceed format * Apply suggestions from code review * add optimization flag * remove line breaks * Apply suggestions from code review * avoid python in macro better * add rust example * format * Apply suggestions from code review * move rust example to own directory * Simplify python exclusion logic * re-fix python * Update python/build_ceed_cffi.py * change names and simplify makefile * Revert "change names and simplify makefile" This reverts commit 96e762f. * Apply Jeremy's diff * Simplify CeedCallSystem * use rust-install llvm tools * add gitignores * update paths * example absolute path * fix comments * apply partial diff * add newline * add makefile * Update examples/rust-qfunctions/Makefile * update makefile --------- Co-authored-by: Allen MacFarland <alma4974@noether>
1 parent 1ad4660 commit 2027fb9

File tree

24 files changed

+1123
-74
lines changed

24 files changed

+1123
-74
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: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,57 @@ 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=4
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+
# libCEED
197+
- make configure OPT='-O -march=native -ffp-contract=fast' CUDA_DIR=/usr/local/cuda-12.9
198+
- echo "-------------- libCEED -------------" && make info
199+
- make clean
200+
- make -k -j$NPROC_CPU -l$NPROC_CPU
201+
# -- libCEED only tests
202+
- echo "-------------- Rust QFunction tests -"
203+
# Note: PETSC_DIR is set by default in GitLab runner env, unsetting to isolate core tests
204+
- export PETSC_DIR= PETSC_ARCH=
205+
- make -k -j$((NPROC_GPU / NPROC_POOL)) JUNIT_BATCH="rust-qfunction" junit realsearch=rust-qfunction
206+
# Report status
207+
- touch .SUCCESS
208+
after_script:
209+
- |
210+
if [ -f .SUCCESS ]; then
211+
lcov --directory . --capture --output-file coverage.info --ignore-errors source,mismatch;
212+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F interface;
213+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F gallery;
214+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F backends;
215+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F tests;
216+
bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_ACCESS_TOKEN} -F examples;
217+
fi
218+
artifacts:
219+
paths:
220+
- build/*.junit
221+
reports:
222+
junit: build/*.junit
223+
224+
174225
# ----------------------------------------------------------------------------------------
175226
# CUDA backends
176227
# ----------------------------------------------------------------------------------------

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+
$(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) -f temp_*
907920

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

0 commit comments

Comments
 (0)