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
27 changes: 25 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ MAGMA_DIR ?= ../magma
# env variable CUTLASS_DIR can be used too
CUTLASS_DIR ?= ../cutlass

# env variable to point the location of KOKKOS installation built with CUDA
KOKKOS_DIR ?=

# ------------------------------------------------------------
# Compiler flags
Expand Down Expand Up @@ -429,6 +431,8 @@ magma.h := $(sort $(wildcard backends/magma/*.h))
magma.hpp := $(sort $(wildcard backends/magma/*.hpp))
cutlass.c := $(sort $(wildcard backends/cutlass/*.c))
cutlass.h := $(sort $(wildcard backends/cutlass/*.h))
kokkos.cpp := $(sort $(wildcard backends/kokkos/*.cpp))
kokkos.hpp := $(sort $(wildcard backends/kokkos/*.hpp))

# Tests
tests.c := $(sort $(wildcard tests/t[0-9][0-9][0-9]-*.c))
Expand Down Expand Up @@ -550,7 +554,8 @@ info:
$(info ROCM_DIR = $(ROCM_DIR)$(call backend_status,$(HIP_BACKENDS)))
$(info SYCL_DIR = $(SYCL_DIR)$(call backend_status,$(SYCL_BACKENDS)))
$(info MAGMA_DIR = $(MAGMA_DIR)$(call backend_status,$(MAGMA_BACKENDS)))
$(info CUTLASS_DIR = $(CUTLASS_DIR)$(call backend_status,$(CUTLASS_BACKENDS)))
$(info CUTLASS_DIR = $(CUTLASS_DIR)$(call backend_status,$(CUTLASS_BACKENDS)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$(info CUTLASS_DIR = $(CUTLASS_DIR)$(call backend_status,$(CUTLASS_BACKENDS)))
$(info CUTLASS_DIR = $(CUTLASS_DIR)$(call backend_status,$(CUTLASS_BACKENDS)))

$(info KOKKOS_DIR = $(KOKKOS_DIR)$(call backend_status,$(KOKKOS_BACKENDS)))
$(info )
$(info -----------------------------------------)
$(info )
Expand Down Expand Up @@ -851,6 +856,22 @@ BACKENDS_MAKE += $(CUTLASS_BACKENDS)

CPPFLAGS += -DCEED_CPU_LINK_ARGS='$(CEED_CPU_LINK_ARGS)'

# Kokkos Backend (requires Kokkos built with CUDA)
KOKKOS_CUDA := $(shell grep -qsE '^$(HASH)define KOKKOS_ENABLE_CUDA( |$$)' $(KOKKOS_DIR)/include/KokkosCore_config.h && echo 1) # looks for '#define KOKKOS_ENABLE_CUDA' in the kokkos config file
ifneq ($(and $(KOKKOS_CUDA),$(CUDA_LIB_DIR)),) # enters inside if kokkos has cuda enabled & cuda is installed
KOKKOS_CXXFLAGS ?= -std=c++20 --extended-lambda # extra compiler flags
kokkos.o := $(kokkos.cpp:%.cpp=$(OBJDIR)/%.o) # converting the list of kokkos .cpp backend files to .o, so that we can append the nvcc_wrapper
$(kokkos.o) : CXX := $(abspath $(KOKKOS_DIR))/bin/nvcc_wrapper
$(kokkos.o) : CXXFLAGS := $(filter-out -std=c++11 -MMD -MP,$(CXXFLAGS)) $(KOKKOS_CXXFLAGS) $(if $(strip $(CUDA_ARCH)),-arch=$(CUDA_ARCH)) # without -arch, nvcc_wrapper defaults to sm_80
$(kokkos.o) $(kokkos.cpp:%=%.tidy) $(kokkos.cpp:%=%.tidy-fix) $(kokkos.hpp:%=%.tidy-fix) : CPPFLAGS += -isystem $(abspath $(KOKKOS_DIR))/include $(CUDA_CPPFLAGS)
PKG_LIBS += -L$(abspath $(KOKKOS_DIR))/lib -L$(abspath $(KOKKOS_DIR))/lib64 -lkokkoscontainers -lkokkoscore -ldl
LIBCEED_CONTAINS_CXX = 1
libceed.cpp += $(kokkos.cpp)
libceed.hpp += $(kokkos.hpp)
KOKKOS_BACKENDS = /gpu/cuda/kokkos
endif
BACKENDS_MAKE += $(KOKKOS_BACKENDS)

BACKENDS ?= $(BACKENDS_MAKE)
export BACKENDS

Expand Down Expand Up @@ -1282,7 +1303,9 @@ print :
CONFIG_VARS = CC CXX FC NVCC NVCC_CXX HIPCC \
OPT CFLAGS CPPFLAGS CXXFLAGS FFLAGS NVCCFLAGS HIPCCFLAGS SYCLFLAGS \
AR ARFLAGS LDFLAGS LDLIBS LIBCXX SED \
MAGMA_DIR CUTLASS_DIR XSMM_DIR CUDA_DIR CUDA_ARCH CUDA_TARGETS MFEM_DIR PETSC_DIR NEK5K_DIR ROCM_DIR HIP_ARCH SYCL_DIR
MAGMA_DIR CUTLASS_DIR XSMM_DIR CUDA_DIR CUDA_ARCH CUDA_TARGETS \
MFEM_DIR PETSC_DIR NEK5K_DIR ROCM_DIR HIP_ARCH SYCL_DIR \
KOKKOS_DIR KOKKOS_CXXFLAGS

# $(call needs_save,CFLAGS) returns true (a nonempty string) if CFLAGS
# was set on the command line or in config.mk (where it will appear as
Expand Down
12 changes: 12 additions & 0 deletions backends/ceed-backend-list-kokkos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2017-2026, 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

// This header does not have guards because it is included multiple times.
// This will be expanded inside CeedRegisterAll() to call each registration function.
// This is also used to create weakly linked registration functions in `backends/weak/ceed-*-weak.c'.

CEED_BACKEND(CeedRegister_Kokkos, 1, "/gpu/cuda/kokkos")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CEED_BACKEND(CeedRegister_Kokkos, 1, "/gpu/cuda/kokkos")
CEED_BACKEND(CeedRegister_Kokkos, 1, "/gpu/cuda/kokkos")

minor

2 changes: 2 additions & 0 deletions backends/ceed-backend-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@
#include "ceed-backend-list-magma.h"
// Requires CUTLASS + CUDA
#include "ceed-backend-list-cutlass.h"
// Requires Kokkos + CUDA
#include "ceed-backend-list-kokkos.h"
Loading