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
2 changes: 1 addition & 1 deletion .github/workflows/rust-test-with-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
strategy:
matrix:
os: [ubuntu-24.04]
os: [ubuntu-24.04, macos-15]
compiler: [clang]

runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ noether-cpu:
- cd .. && export NEK5K_VERSION=Nek5000-19.0 && { [[ -d $NEK5K_VERSION ]] || { git clone --depth 1 --branch v19.0 https://github.com/Nek5000/Nek5000.git $NEK5K_VERSION && cd $NEK5K_VERSION/tools && ./maketools genbox genmap reatore2 && cd ../..; }; } && export NEK5K_DIR=$PWD/$NEK5K_VERSION && export PATH=$NEK5K_DIR/bin:$PATH MPI=0 && cd libCEED
- echo "-------------- Nek5000 -------------" && git -C $NEK5K_DIR describe --tags
- export NPROC_POOL=1
- make -k -j$NPROC_CPU BACKENDS="$BACKENDS_CPU" JUNIT_BATCH="cpu" junit search=nek NEK5K_DIR=$NEK5K_DIR
- make -B -k -j$NPROC_CPU BACKENDS="$BACKENDS_CPU" JUNIT_BATCH="cpu" junit search=nek NEK5K_DIR=$NEK5K_DIR
# -- deal.II 8bd5c262f13e15793aa206b6eed8774a9b25ce11
- BACKENDS_CPU=$(make info-backends-all | grep -o '/cpu[^ ]*' | tr '\n' ' ')
- export DEAL_II_ROOT_DIR=/projects/dealii DEAL_II_DIR=/projects/dealii/install
Expand Down Expand Up @@ -277,7 +277,7 @@ noether-cuda:
- cd .. && export NEK5K_VERSION=Nek5000-19.0 && { [[ -d $NEK5K_VERSION ]] || { git clone --depth 1 --branch v19.0 https://github.com/Nek5000/Nek5000.git $NEK5K_VERSION && cd $NEK5K_VERSION/tools && ./maketools genbox genmap reatore2 && cd ../..; }; } && export NEK5K_DIR=$PWD/$NEK5K_VERSION && export PATH=$NEK5K_DIR/bin:$PATH MPI=0 && cd libCEED
- echo "-------------- Nek5000 -------------" && git -C $NEK5K_DIR describe --tags
- export NPROC_POOL=1
- make -k -j$NPROC_GPU BACKENDS="$BACKENDS_GPU" JUNIT_BATCH="cuda" junit search=nek NEK5K_DIR=$NEK5K_DIR
- make -B -k -j$NPROC_GPU BACKENDS="$BACKENDS_GPU" JUNIT_BATCH="cuda" junit search=nek NEK5K_DIR=$NEK5K_DIR
# -- deal.II 8bd5c262f13e15793aa206b6eed8774a9b25ce11
- export DEAL_II_ROOT_DIR=/projects/dealii DEAL_II_DIR=/projects/dealii/install
- echo "-------------- deal.II -------------" && git -C $DEAL_II_ROOT_DIR -c safe.directory=$DEAL_II_ROOT_DIR describe --always
Expand Down
34 changes: 21 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ quiet ?= $($(1))
.PRECIOUS: %/.DIR


DARWIN := $(filter Darwin,$(shell uname -s))


# ------------------------------------------------------------
# Root directories for backend dependencies
# ------------------------------------------------------------
Expand Down Expand Up @@ -72,7 +75,7 @@ ifeq (,$(filter-out undefined default,$(origin AR)))
AR = ar
endif
ifeq (,$(filter-out undefined default,$(origin ARFLAGS)))
ARFLAGS = crD
ARFLAGS = $(if $(DARWIN),cr,crD)
endif
NVCC ?= $(CUDA_DIR)/bin/nvcc
NVCC_CXX ?= $(CXX)
Expand Down Expand Up @@ -222,7 +225,6 @@ MFLAGS := -j $(NPROCS) --warn-undefined-variables \
PYTHON ?= python3
PROVE ?= prove
PROVE_OPTS ?= -j $(NPROCS)
DARWIN := $(filter Darwin,$(shell uname -s))
SO_EXT := $(if $(DARWIN),dylib,so)

ceed.pc := $(LIBDIR)/pkgconfig/ceed.pc
Expand Down Expand Up @@ -486,9 +488,10 @@ MEMCHK_STATUS = Disabled
MEMCHK := $(shell echo "$(HASH)include <valgrind/memcheck.h>" | $(CC) $(CPPFLAGS) -E - >/dev/null 2>&1 && echo 1)
MEMCHK_BACKENDS = /cpu/self/memcheck/serial /cpu/self/memcheck/blocked
ifeq ($(MEMCHK),1)
MEMCHK_STATUS = Enabled
libceed.c += $(ceedmemcheck.c)
MEMCHK_STATUS = Enabled
libceed.c += $(ceedmemcheck.c)
BACKENDS_MAKE += $(MEMCHK_BACKENDS)
CFLAGS += "-DCEED_USE_MEMCHECK"
endif

# AVX Backeds
Expand All @@ -497,9 +500,10 @@ AVX_FLAG := $(if $(filter clang,$(CC_VENDOR)),+avx,-mavx)
AVX := $(filter $(AVX_FLAG),$(shell $(CC) $(CFLAGS:-M%=) -v -E -x c /dev/null 2>&1))
AVX_BACKENDS = /cpu/self/avx/serial /cpu/self/avx/blocked
ifneq ($(AVX),)
AVX_STATUS = Enabled
libceed.c += $(avx.c)
AVX_STATUS = Enabled
libceed.c += $(avx.c)
BACKENDS_MAKE += $(AVX_BACKENDS)
CFLAGS += "-DCEED_USE_AVX"
endif

# Collect list of libraries and paths for use in linking and pkg-config
Expand All @@ -522,10 +526,11 @@ ifneq ($(wildcard $(XSMM_DIR)/lib/libxsmm.*),)
endif
BLAS_LIB ?= $(MKL_LINK) -Wl,--push-state,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl -Wl,--pop-state
endif
PKG_LIBS += $(BLAS_LIB)
PKG_LIBS += $(BLAS_LIB)
libceed.c += $(xsmm.c)
$(xsmm.c:%.c=$(OBJDIR)/%.o) $(xsmm.c:%=%.tidy) : CPPFLAGS += -I$(XSMM_DIR)/include
BACKENDS_MAKE += $(XSMM_BACKENDS)
CFLAGS += "-DCEED_USE_XSMM"
endif

# CUDA Backends
Expand All @@ -537,14 +542,15 @@ CUDA_LIB_DIR_STUBS := $(CUDA_LIB_DIR)/stubs
CUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/shared /gpu/cuda/gen
ifneq ($(CUDA_LIB_DIR),)
$(libceeds) : CPPFLAGS += -I$(CUDA_DIR)/include
PKG_LIBS += -L$(abspath $(CUDA_LIB_DIR)) -lcudart -lnvrtc -lcuda -lcublas
PKG_LIBS += -L$(abspath $(CUDA_LIB_DIR)) -lcudart -lnvrtc -lcuda -lcublas
PKG_STUBS_LIBS += -L$(CUDA_LIB_DIR_STUBS)
LIBCEED_CONTAINS_CXX = 1
libceed.c += interface/ceed-cuda.c
libceed.c += $(cuda-all.c)
libceed.cpp += $(cuda-all.cpp)
libceed.cu += $(cuda-all.cu)
BACKENDS_MAKE += $(CUDA_BACKENDS)
CFLAGS += "-DCEED_USE_CUDA"
endif

# HIP Backends
Expand All @@ -563,6 +569,7 @@ ifneq ($(HIP_LIB_DIR),)
libceed.cpp += $(hip-all.cpp)
libceed.hip += $(hip-all.hip)
BACKENDS_MAKE += $(HIP_BACKENDS)
CFLAGS += "-DCEED_USE_HIP"
endif

# SYCL Backends
Expand All @@ -576,6 +583,7 @@ ifneq ($(SYCL_LIB_DIR),)
LIBCEED_CONTAINS_CXX = 1
libceed.sycl += $(sycl-core.cpp) $(sycl-ref.cpp) $(sycl-shared.cpp) $(sycl-gen.cpp)
BACKENDS_MAKE += $(SYCL_BACKENDS)
CFLAGS += "-DCEED_USE_SYCL"
endif

# MAGMA Backends
Expand Down Expand Up @@ -612,6 +620,7 @@ ifneq ($(wildcard $(MAGMA_DIR)/lib/libmagma.*),)
endif
LIBCEED_CONTAINS_CXX = 1
BACKENDS_MAKE += $(MAGMA_BACKENDS)
CFLAGS += "-DCEED_USE_MAGMA"
endif

BACKENDS ?= $(BACKENDS_MAKE)
Expand Down Expand Up @@ -645,17 +654,16 @@ endif
# Building core library components
# ------------------------------------------------------------

# File names *-weak.c contain weak symbol definitions, which must be listed last
# when creating shared or static libraries.
weak_last = $(filter-out %-weak.o,$(1)) $(filter %-weak.o,$(1))
FORCE:
$(OBJDIR)/backends/ceed-backend-register.o: FORCE

libceed.o = $(libceed.c:%.c=$(OBJDIR)/%.o) $(libceed.cpp:%.cpp=$(OBJDIR)/%.o) $(libceed.cu:%.cu=$(OBJDIR)/%.o) $(libceed.hip:%.hip.cpp=$(OBJDIR)/%.o) $(libceed.sycl:%.sycl.cpp=$(OBJDIR)/%.o)
$(filter %fortran.o,$(libceed.o)) : CPPFLAGS += $(if $(filter 1,$(UNDERSCORE)),-DUNDERSCORE)
$(libceed.o): | info-backends
$(libceed.so) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR
$(libceed.so) : $(libceed.o) | $$(@D)/.DIR
$(call quiet,LINK) $(LDFLAGS) $(CEED_LDFLAGS) -shared -o $@ $^ $(CEED_LDLIBS) $(LDLIBS)

$(libceed.a) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR
$(libceed.a) : $(libceed.o) | $$(@D)/.DIR
$(call quiet,AR) $(ARFLAGS) $@ $^

$(OBJDIR)/%.o : $(CURDIR)/%.c | $$(@D)/.DIR
Expand Down
8 changes: 2 additions & 6 deletions backends/avx/ceed-avx-blocked.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
#include <stdbool.h>
#include <string.h>

#include "../ceed-backend-init.h"
#include "ceed-avx.h"

//------------------------------------------------------------------------------
// Backend Init
//------------------------------------------------------------------------------
static int CeedInit_Avx(const char *resource, Ceed ceed) {
CEED_INTERN int CeedInit_Avx_Blocked(const char *resource, Ceed ceed) {
Ceed ceed_ref;

CeedCheck(!strcmp(resource, "/cpu/self") || !strcmp(resource, "/cpu/self/avx") || !strcmp(resource, "/cpu/self/avx/blocked"), ceed,
Expand All @@ -32,8 +33,3 @@ static int CeedInit_Avx(const char *resource, Ceed ceed) {
}

//------------------------------------------------------------------------------
// Backend Register
//------------------------------------------------------------------------------
CEED_INTERN int CeedRegister_Avx_Blocked(void) { return CeedRegister("/cpu/self/avx/blocked", CeedInit_Avx, 30); }

//------------------------------------------------------------------------------
8 changes: 2 additions & 6 deletions backends/avx/ceed-avx-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
#include <stdbool.h>
#include <string.h>

#include "../ceed-backend-init.h"
#include "ceed-avx.h"

//------------------------------------------------------------------------------
// Backend Init
//------------------------------------------------------------------------------
static int CeedInit_Avx(const char *resource, Ceed ceed) {
CEED_INTERN int CeedInit_Avx_Serial(const char *resource, Ceed ceed) {
Ceed ceed_ref;

CeedCheck(!strcmp(resource, "/cpu/self") || !strcmp(resource, "/cpu/self/avx/serial"), ceed, CEED_ERROR_BACKEND,
Expand All @@ -32,8 +33,3 @@ static int CeedInit_Avx(const char *resource, Ceed ceed) {
}

//------------------------------------------------------------------------------
// Backend Register
//------------------------------------------------------------------------------
CEED_INTERN int CeedRegister_Avx_Serial(void) { return CeedRegister("/cpu/self/avx/serial", CeedInit_Avx, 35); }

//------------------------------------------------------------------------------
12 changes: 4 additions & 8 deletions backends/blocked/ceed-blocked.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
//
// This file is part of CEED: http://github.com/ceed

#include "ceed-blocked.h"

#include <ceed.h>
#include <ceed/backend.h>
#include <stdbool.h>
#include <string.h>

#include "../ceed-backend-init.h"
#include "ceed-blocked.h"

//------------------------------------------------------------------------------
// Backend Init
//------------------------------------------------------------------------------
static int CeedInit_Blocked(const char *resource, Ceed ceed) {
CEED_INTERN int CeedInit_Ref_Blocked(const char *resource, Ceed ceed) {
Ceed ceed_ref;

CeedCheck(!strcmp(resource, "/cpu/self") || !strcmp(resource, "/cpu/self/ref/blocked"), ceed, CEED_ERROR_BACKEND,
Expand All @@ -32,8 +33,3 @@ static int CeedInit_Blocked(const char *resource, Ceed ceed) {
}

//------------------------------------------------------------------------------
// Backend Register
//------------------------------------------------------------------------------
CEED_INTERN int CeedRegister_Ref_Blocked(void) { return CeedRegister("/cpu/self/ref/blocked", CeedInit_Blocked, 55); }

//------------------------------------------------------------------------------
14 changes: 14 additions & 0 deletions backends/ceed-backend-init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) 2017-2025, Lawrence Livermore National Security, LLC and other CEED contributors.
// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
//
// SPDX-License-Identifier: BSD-2-Clause
//
// This file is part of CEED: http://github.com/ceed
#pragma once

#include <ceed/backend.h>

#undef CEED_BACKEND
#define CEED_BACKEND(name, ...) CEED_INTERN int CeedInit_##name(const char *resource, Ceed ceed);
#include "../backends/ceed-backend-list.h"
#undef CEED_BACKEND
94 changes: 69 additions & 25 deletions backends/ceed-backend-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,72 @@

// This header does not have guards because it is included multiple times.

// List each backend registration function once here.
// This will be expanded inside CeedRegisterAll() to call each registration function in the order listed, and also to define weak symbol aliases for
// backends that are not configured.

CEED_BACKEND(CeedRegister_Avx_Blocked, 1, "/cpu/self/avx/blocked")
CEED_BACKEND(CeedRegister_Avx_Serial, 1, "/cpu/self/avx/serial")
CEED_BACKEND(CeedRegister_Cuda, 1, "/gpu/cuda/ref")
CEED_BACKEND(CeedRegister_Cuda_Gen, 1, "/gpu/cuda/gen")
CEED_BACKEND(CeedRegister_Cuda_Shared, 1, "/gpu/cuda/shared")
CEED_BACKEND(CeedRegister_Hip, 1, "/gpu/hip/ref")
CEED_BACKEND(CeedRegister_Hip_Gen, 1, "/gpu/hip/gen")
CEED_BACKEND(CeedRegister_Hip_Shared, 1, "/gpu/hip/shared")
CEED_BACKEND(CeedRegister_Sycl, 1, "/gpu/sycl/ref")
CEED_BACKEND(CeedRegister_Sycl_Shared, 1, "/gpu/sycl/shared")
CEED_BACKEND(CeedRegister_Sycl_Gen, 1, "/gpu/sycl/gen")
CEED_BACKEND(CeedRegister_Magma, 2, "/gpu/cuda/magma", "/gpu/hip/magma")
CEED_BACKEND(CeedRegister_Magma_Det, 2, "/gpu/cuda/magma/det", "/gpu/hip/magma/det")
CEED_BACKEND(CeedRegister_Memcheck_Blocked, 1, "/cpu/self/memcheck/blocked")
CEED_BACKEND(CeedRegister_Memcheck_Serial, 1, "/cpu/self/memcheck/serial")
CEED_BACKEND(CeedRegister_Opt_Blocked, 1, "/cpu/self/opt/blocked")
CEED_BACKEND(CeedRegister_Opt_Serial, 1, "/cpu/self/opt/serial")
CEED_BACKEND(CeedRegister_Ref, 1, "/cpu/self/ref/serial")
CEED_BACKEND(CeedRegister_Ref_Blocked, 1, "/cpu/self/ref/blocked")
CEED_BACKEND(CeedRegister_Xsmm_Blocked, 1, "/cpu/self/xsmm/blocked")
CEED_BACKEND(CeedRegister_Xsmm_Serial, 1, "/cpu/self/xsmm/serial")
// List each backend function suffix once here.
// The CEED_BACKEND(name, suffix, is_enabled, num_prefixes, prefix_0, priority_0, ...) macro is used in several places.
//
// This list will be expanded inside ceed-backend-init.h to declare all initialization functions of the form CeedInit_##name(resource, ceed).
// These functions must be defined in their respective backends.
//
// This list will be expanded inside ceed-backend-register.h to declare all initialization functions of the form CeedRegister_##name##suffix(void).
// These functions are defined ceed-register.c.
//
// In ceed-register.c, if the backend is enabled, then CeedRegister_##name##suffix(void) registers each prefix with the corresponding priority and uses CeedInit_##name.
// If the backend is not enabled, then CeedRegister_##name##suffix(void) registers each prefix with an initialization function that gives an error message.
//
// This list is expanded inside CeedRegisterAll() to call each registration function in the order listed.

CEED_BACKEND(Ref_Serial, , true, 1, "/cpu/self/ref/serial", 50)
CEED_BACKEND(Ref_Blocked, , true, 1, "/cpu/self/ref/blocked", 55)
CEED_BACKEND(Opt_Serial, , true, 1, "/cpu/self/opt/serial", 40)
CEED_BACKEND(Opt_Blocked, , true, 1, "/cpu/self/opt/blocked", 45)

#ifndef CEED_USE_MEMCHECK
#define CEED_USE_MEMCHECK false
#endif
CEED_BACKEND(Memcheck_Serial, , CEED_USE_MEMCHECK, 1, "/cpu/self/memcheck/serial", 100)
CEED_BACKEND(Memcheck_Blocked, , CEED_USE_MEMCHECK, 1, "/cpu/self/memcheck/blocked", 110)

#ifndef CEED_USE_AVX
#define CEED_USE_AVX false
#endif
CEED_BACKEND(Avx_Serial, , CEED_USE_AVX, 1, "/cpu/self/avx/serial", 30)
CEED_BACKEND(Avx_Blocked, , CEED_USE_AVX, 1, "/cpu/self/avx/blocked", 30)

#ifndef CEED_USE_XSMM
#define CEED_USE_XSMM false
#endif
CEED_BACKEND(Xsmm_Serial, , CEED_USE_XSMM, 1, "/cpu/self/xsmm/serial", 20)
CEED_BACKEND(Xsmm_Blocked, , CEED_USE_XSMM, 1, "/cpu/self/xsmm/blocked", 25)

#ifndef CEED_USE_CUDA
#define CEED_USE_CUDA false
#endif
CEED_BACKEND(Cuda_Ref, , CEED_USE_CUDA, 1, "/gpu/cuda/ref", 40)
CEED_BACKEND(Cuda_Shared, , CEED_USE_CUDA, 1, "/gpu/cuda/shared", 30)
CEED_BACKEND(Cuda_Gen, , CEED_USE_CUDA, 1, "/gpu/cuda/gen", 20)

#ifndef CEED_USE_HIP
#define CEED_USE_HIP false
#endif
CEED_BACKEND(Hip_Ref, , CEED_USE_HIP, 1, "/gpu/hip/ref", 40)
CEED_BACKEND(Hip_Shared, , CEED_USE_HIP, 1, "/gpu/hip/shared", 30)
CEED_BACKEND(Hip_Gen, , CEED_USE_HIP, 1, "/gpu/hip/gen", 20)

#ifndef CEED_USE_SYCL
#define CEED_USE_SYCL false
#endif
CEED_BACKEND(Sycl_Ref, , CEED_USE_SYCL, 2, "/gpu/sycl/ref", 40, "/cpu/sycl/ref", 45)
CEED_BACKEND(Sycl_Shared, , CEED_USE_SYCL, 2, "/gpu/sycl/shared", 30, "/cpu/sycl/shared", 35)
CEED_BACKEND(Sycl_Gen, , CEED_USE_SYCL, 1, "/gpu/sycl/gen", 20)

#ifndef CEED_MAGMA_USE_CUDA
#define CEED_MAGMA_USE_CUDA false
#endif
CEED_BACKEND(Magma, _Cuda, CEED_MAGMA_USE_CUDA, 1, "/gpu/cuda/magma", 120)
CEED_BACKEND(Magma_Det, _Cuda, CEED_MAGMA_USE_CUDA, 1, "/gpu/cuda/magma/det", 125)

#ifndef CEED_MAGMA_USE_HIP
#define CEED_MAGMA_USE_HIP false
#endif
CEED_BACKEND(Magma, _Hip, CEED_MAGMA_USE_HIP, 1, "/gpu/hip/magma", 120)
CEED_BACKEND(Magma_Det, _Hip, CEED_MAGMA_USE_HIP, 1, "/gpu/hip/magma/det", 125)
Loading