From 0be03a92683d319639505fd4b3dce80b3bae318f Mon Sep 17 00:00:00 2001 From: Jeremy L Thompson Date: Thu, 13 Oct 2022 10:45:56 -0600 Subject: [PATCH] Update OCCA Backend (#1072) * Update OCCA memory interop call. * Removes deprecated kernelBuilder calls; builds directly from the device. * Uses `std::memset` and `std:memcpy`. * Uses `std::to_string` instead of internal `occa::toString`. * Uses `std::memcpy`. * Sets kernel properties. * Removes deprecated kernelBuilder calls; builds directly from the device. * Removes deprecated kernelBuild call; builds directly from the device. * Uses `std::memcpy`. * Removes deprecated calls to `occa::linalg`. * Add registration and device configuration for DPC++ and OpenCL backends. * Add DPC++ and OpenCL backends to makefile. * Spelling. * Configure build flags for oneAPI compilers. * Correctly set mode in `occa::json` object. * Add missing functions to OCCA CeedVector implementation. * Adds missing call to `setValueKernel` in OCCA CeedVector impl. * Gets occa device function name from the CeedQFunction. * Adds OpenCL and DPC++ to backends list. * Uses unique kernel name for OCCA qFunction kernels. * Adds a dummy `ceed.h` header in include in OCCA kernels. * Rewrite arrays of structs in format that OCCA can handle. * Adds stubs for missing functions in OCCA qfunctioncontext. * Includes the cmath header when compiling C++ code. * Add stubs for missing OCCA backend LinearAssembleXXX functions. * Adds missing functions to OCCA implemenation of qFunctionContext. * Removes math function headers which were causing OCCA JIT failures. * Rewrite arrays of structs in format that OCCA can handle. * Rewrites fluids example qfunctions to be compatible with OCCA. * Fixes array dimensions in mass2dbuild. * Rewrites advection problem kernels to work with OCCA. * Rewrites blasius problem kernels to work with OCCA. * Rewrites channel problem kernels to work with OCCA. * Rewrites dirichlet bc kernels to work with OCCA. * Rewrites newtonian kernels to work with OCCA. * Rewrites setupgeo kernels to be compatible with OCCA. * Rewrites stabilization kernels to be compatible with OCCA. * Rewrites stg kernels to be compatible with OCCA. * Adds occa backends to tests for the fluids example. * doc - update OCCA info in release notes + README * ci - run with OCCA v1.4 * occa - update copyright boilerplate * occa - drop unused define * ci - fix OCCA install * wip * ci - fix occa skip list * make/ci - fix use of OCCA_DIR/bin/occa * makefile - minor style * ci - re-enable OCCA dir caching * doc - update release notes to mention OCCA QF workarounds Co-authored-by: Kris Rowe --- .gitlab-ci.yml | 10 +- Makefile | 19 +- README.md | 4 +- backends/ceed-backend-list.h | 2 +- backends/occa/ceed-occa-basis.cpp | 17 +- backends/occa/ceed-occa-basis.hpp | 17 +- backends/occa/ceed-occa-ceed-object.cpp | 17 +- backends/occa/ceed-occa-ceed-object.hpp | 17 +- backends/occa/ceed-occa-context.cpp | 17 +- backends/occa/ceed-occa-context.hpp | 17 +- backends/occa/ceed-occa-cpu-operator.cpp | 18 +- backends/occa/ceed-occa-cpu-operator.hpp | 17 +- backends/occa/ceed-occa-elem-restriction.cpp | 111 +++++----- backends/occa/ceed-occa-elem-restriction.hpp | 24 +-- backends/occa/ceed-occa-gpu-operator.cpp | 17 +- backends/occa/ceed-occa-gpu-operator.hpp | 17 +- backends/occa/ceed-occa-kernels.hpp | 18 +- backends/occa/ceed-occa-operator-args.cpp | 17 +- backends/occa/ceed-occa-operator-args.hpp | 17 +- backends/occa/ceed-occa-operator-field.cpp | 17 +- backends/occa/ceed-occa-operator-field.hpp | 17 +- backends/occa/ceed-occa-operator.cpp | 23 +-- backends/occa/ceed-occa-operator.hpp | 18 +- backends/occa/ceed-occa-qfunction-args.cpp | 17 +- backends/occa/ceed-occa-qfunction-args.hpp | 17 +- backends/occa/ceed-occa-qfunction-field.cpp | 17 +- backends/occa/ceed-occa-qfunction-field.hpp | 17 +- backends/occa/ceed-occa-qfunction.cpp | 47 ++--- backends/occa/ceed-occa-qfunction.hpp | 20 +- backends/occa/ceed-occa-qfunctioncontext.cpp | 77 +++++-- backends/occa/ceed-occa-qfunctioncontext.hpp | 32 +-- backends/occa/ceed-occa-simplex-basis.cpp | 171 ++++++---------- backends/occa/ceed-occa-simplex-basis.hpp | 48 ++--- backends/occa/ceed-occa-tensor-basis.cpp | 190 ++++++++---------- backends/occa/ceed-occa-tensor-basis.hpp | 53 ++--- backends/occa/ceed-occa-types.hpp | 17 +- backends/occa/ceed-occa-vector.cpp | 103 ++++++++-- backends/occa/ceed-occa-vector.hpp | 38 ++-- backends/occa/ceed-occa.cpp | 71 ++++--- backends/occa/kernels/elem-restriction.cpp | 17 +- backends/occa/kernels/elem-restriction.hpp | 17 +- backends/occa/kernels/kernel-defines.hpp | 17 +- backends/occa/kernels/set-value.cpp | 26 +++ backends/occa/kernels/set-value.hpp | 20 ++ backends/occa/kernels/simplex-basis.hpp | 17 +- .../simplex-basis/cpu-simplex-basis.cpp | 17 +- .../simplex-basis/gpu-simplex-basis.cpp | 17 +- backends/occa/kernels/tensor-basis.hpp | 17 +- .../tensor-basis/cpu/tensor-basis-1d.cpp | 17 +- .../tensor-basis/cpu/tensor-basis-2d.cpp | 17 +- .../tensor-basis/cpu/tensor-basis-3d.cpp | 17 +- .../tensor-basis/gpu/tensor-basis-1d.cpp | 17 +- .../tensor-basis/gpu/tensor-basis-2d.cpp | 17 +- .../tensor-basis/gpu/tensor-basis-3d.cpp | 17 +- doc/sphinx/source/releasenotes.md | 3 + tests/junit.py | 8 +- 56 files changed, 712 insertions(+), 969 deletions(-) create mode 100644 backends/occa/kernels/set-value.cpp create mode 100644 backends/occa/kernels/set-value.hpp diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2afaed06e1..5e3ee5ecf4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,20 +22,16 @@ noether-cpu: - cd .. && export XSMM_HASH=44433be9426eddaed88415646c15b3bcc61afc85 && { [[ -d libxsmm-$XSMM_HASH ]] || { curl -L https://github.com/libxsmm/libxsmm/archive/$XSMM_HASH.tar.gz -o xsmm.tar.gz && tar zvxf xsmm.tar.gz && rm xsmm.tar.gz && make -C libxsmm-$XSMM_HASH -j$(nproc); }; } && export XSMM_DIR=$PWD/libxsmm-$XSMM_HASH && cd libCEED - echo "-------------- LIBXSMM -------------" && basename $XSMM_DIR # -- OCCA v1.1.0 - - cd .. && export OCCA_VERSION=occa-1.1.0 OCCA_OPENCL_ENABLED=0 && { [[ -d $OCCA_VERSION ]] || { git clone --depth 1 --branch v1.1.0 https://github.com/libocca/occa.git $OCCA_VERSION && sed -i '/sysctl.h/d' $OCCA_VERSION/src/tools/sys.cpp && make -C $OCCA_VERSION -j$(nproc); }; } && export OCCA_DIR=$PWD/$OCCA_VERSION && cd libCEED - - echo "-------------- OCCA ----------------" && make -C $OCCA_DIR info + - cd .. && export OCCA_VERSION=occa-1.4.0 && { [[ -d $OCCA_VERSION ]] || { git clone --depth 1 --branch v1.4.0 https://github.com/libocca/occa.git $OCCA_VERSION && cd $OCCA_VERSION && export ENABLE_OPENCL="OFF" ENABLE_DPCPP="OFF" ENABLE_HIP="OFF" ENABLE_CUDA="OFF" && ./configure-cmake.sh && cmake --build build --parallel $NPROC_CPU && cmake --install build && cd ..; }; } && export OCCA_DIR=$PWD/$OCCA_VERSION/install && cd libCEED + - echo "-------------- OCCA ----------------" && git -C $OCCA_DIR describe --tags && LD_LIBRARY_PATH=$OCCA_DIR/lib $OCCA_DIR/bin/occa info script: - rm -f .SUCCESS # libCEED - make configure OPT='-O -march=native -ffp-contract=fast' -# Note: OCCA backends currently disabled in CI - - BACKENDS_CPU=$(OCCA_DIR= make info-backends-all | grep -o '/cpu[^ ]*') + - BACKENDS_CPU=$(make info-backends-all | grep -o '/cpu[^ ]*') - echo "-------------- libCEED -------------" && make info - echo "-------------- BACKENDS_CPU --------" && echo $BACKENDS_CPU - make -j$NPROC_CPU -# Remove OCCA after verifying it compiles -# CodeCov of OCCA backend not useful since testing is intentionally disabled - - export OCCA_DIR= && make -j$NPROC_CPU -W build/interface/ceed-register.o # -- libCEED only tests - echo "-------------- core tests ----------" - echo '[{"subject":"/","metrics":[{"name":"Transfer Size (KB)","value":"19.5","desiredSize":"smaller"},{"name":"Speed Index","value":0,"desiredSize":"smaller"},{"name":"Total Score","value":92,"desiredSize":"larger"},{"name":"Requests","value":4,"desiredSize":"smaller"}]}]' > performance.json diff --git a/Makefile b/Makefile index e01fd87771..87fbf03c9c 100644 --- a/Makefile +++ b/Makefile @@ -64,11 +64,11 @@ MPI ?= 1 # CEED_DIR env for NEK5K testing export CEED_DIR = $(abspath .) -# XSMM_DIR env variable should point to XSMM master (github.com/hfp/libxsmm) +# XSMM_DIR env variable should point to XSMM main (github.com/hfp/libxsmm) XSMM_DIR ?= ../libxsmm -# OCCA_DIR env variable should point to OCCA master (github.com/libocca/occa) -OCCA_DIR ?= ../occa +# OCCA_DIR env variable should point to OCCA main (github.com/libocca/occa) +OCCA_DIR ?= ../occa/install # env variable MAGMA_DIR can be used too MAGMA_DIR ?= ../magma @@ -92,27 +92,33 @@ AFLAGS = -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer # Note: Intel oneAPI C/C++ compiler is now icx/icpx CC_VENDOR := $(subst icc_orig,icc,$(subst oneAPI,icc,$(firstword $(filter gcc clang icc icc_orig oneAPI XL,$(subst -, ,$(shell $(CC) --version)))))) -FC_VENDOR := $(if $(FC),$(firstword $(filter GNU ifort XL,$(shell $(FC) --version 2>&1 || $(FC) -qversion)))) +FC_VENDOR := $(if $(FC),$(firstword $(filter GNU ifort ifx XL,$(shell $(FC) --version 2>&1 || $(FC) -qversion)))) # Default extra flags by vendor MARCHFLAG.gcc := -march=native MARCHFLAG.clang := $(MARCHFLAG.gcc) MARCHFLAG.icc := +MARCHFLAG.oneAPI := $(MARCHFLAG.clang) OMP_SIMD_FLAG.gcc := -fopenmp-simd OMP_SIMD_FLAG.clang := $(OMP_SIMD_FLAG.gcc) OMP_SIMD_FLAG.icc := -qopenmp-simd +OMP_SIMD_FLAG.oneAPI := $(OMP_SIMD_FLAG.clang) OPT.gcc := -ffp-contract=fast OPT.clang := $(OPT.gcc) +OPT.oneAPI := $(OPT.clang) CFLAGS.gcc := -fPIC -std=c99 -Wall -Wextra -Wno-unused-parameter -MMD -MP CFLAGS.clang := $(CFLAGS.gcc) CFLAGS.icc := $(CFLAGS.gcc) +CFLAGS.oneAPI := $(CFLAGS.clang) CFLAGS.XL := -qpic -MMD CXXFLAGS.gcc := -fPIC -std=c++11 -Wall -Wextra -Wno-unused-parameter -MMD -MP CXXFLAGS.clang := $(CXXFLAGS.gcc) CXXFLAGS.icc := $(CXXFLAGS.gcc) +CXXFLAGS.oneAPI := $(CXXFLAGS.clang) CXXFLAGS.XL := -qpic -std=c++11 -MMD FFLAGS.GNU := -fPIC -cpp -Wall -Wextra -Wno-unused-parameter -Wno-unused-dummy-argument -MMD -MP FFLAGS.ifort := -fPIC -cpp +FFLAGS.ifx := $(FFLAGS.ifort) FFLAGS.XL := -qpic -ffree-form -qpreprocess -qextname -MMD # This check works with compilers that use gcc and clang. It fails with some @@ -369,9 +375,10 @@ endif # OCCA Backends OCCA_BACKENDS = /cpu/self/occa ifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),) - OCCA_MODES := $(shell $(OCCA_DIR)/bin/occa modes) + OCCA_MODES := $(shell LD_LIBRARY_PATH=$(OCCA_DIR)/lib $(OCCA_DIR)/bin/occa modes) OCCA_BACKENDS += $(if $(filter OpenMP,$(OCCA_MODES)),/cpu/openmp/occa) -# OCCA_BACKENDS += $(if $(filter OpenCL,$(OCCA_MODES)),/gpu/opencl/occa) + OCCA_BACKENDS += $(if $(filter dpcpp,$(OCCA_MODES)),/gpu/dpcpp/occa) + OCCA_BACKENDS += $(if $(filter OpenCL,$(OCCA_MODES)),/gpu/opencl/occa) OCCA_BACKENDS += $(if $(filter HIP,$(OCCA_MODES)),/gpu/hip/occa) OCCA_BACKENDS += $(if $(filter CUDA,$(OCCA_MODES)),/gpu/cuda/occa) diff --git a/README.md b/README.md index 75dbff73e7..97882bf306 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,7 @@ There are multiple supported backends, which can be selected at runtime in the e | `/*/occa` | Selects backend based on available OCCA modes | Yes | | `/cpu/self/occa` | OCCA backend with serial CPU kernels | Yes | | `/cpu/openmp/occa` | OCCA backend with OpenMP kernels | Yes | +| `/cpu/dpcpp/occa` | OCCA backend with CPC++ kernels | Yes | | `/gpu/cuda/occa` | OCCA backend with CUDA kernels | Yes | | `/gpu/hip/occa`~ | OCCA backend with HIP kernels | Yes | @@ -198,8 +199,9 @@ For example: The `/*/occa` backends rely upon the [OCCA](http://github.com/libocca/occa) package to provide cross platform performance. To enable the OCCA backend, the environment variable `OCCA_DIR` must point to the top-level OCCA directory, with the OCCA library located in the `${OCCA_DIR}/lib` (By default, `OCCA_DIR` is set to `../occa`). +OCCA version 1.4.0 or newer is required. -Additionally, users can pass specific OCCA device properties after setting the CEED resource. +Users can pass specific OCCA device properties after setting the CEED resource. For example: > - `"/*/occa:mode='CUDA',device_id=0"` diff --git a/backends/ceed-backend-list.h b/backends/ceed-backend-list.h index c8c2e630d7..a8457f15a4 100644 --- a/backends/ceed-backend-list.h +++ b/backends/ceed-backend-list.h @@ -24,7 +24,7 @@ MACRO(CeedRegister_Magma, 2, "/gpu/cuda/magma", "/gpu/hip/magma") MACRO(CeedRegister_Magma_Det, 2, "/gpu/cuda/magma/det", "/gpu/hip/magma/det") MACRO(CeedRegister_Memcheck_Blocked, 1, "/cpu/self/memcheck/blocked") MACRO(CeedRegister_Memcheck_Serial, 1, "/cpu/self/memcheck/serial") -MACRO(CeedRegister_Occa, 4, "/cpu/self/occa", "/cpu/openmp/occa", "/gpu/hip/occa", "/gpu/cuda/occa") +MACRO(CeedRegister_Occa, 6, "/cpu/self/occa", "/cpu/openmp/occa", "/gpu/dpcpp/occa", "/gpu/opencl/occa", "/gpu/hip/occa", "/gpu/cuda/occa") MACRO(CeedRegister_Opt_Blocked, 1, "/cpu/self/opt/blocked") MACRO(CeedRegister_Opt_Serial, 1, "/cpu/self/opt/serial") MACRO(CeedRegister_Ref, 1, "/cpu/self/ref/serial") diff --git a/backends/occa/ceed-occa-basis.cpp b/backends/occa/ceed-occa-basis.cpp index f5252d0ab7..5590298cf1 100644 --- a/backends/occa/ceed-occa-basis.cpp +++ b/backends/occa/ceed-occa-basis.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-basis.hpp" #include "ceed-occa-tensor-basis.hpp" diff --git a/backends/occa/ceed-occa-basis.hpp b/backends/occa/ceed-occa-basis.hpp index d17e6f963b..53c8e78f6b 100644 --- a/backends/occa/ceed-occa-basis.hpp +++ b/backends/occa/ceed-occa-basis.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_BASIS_HEADER #define CEED_OCCA_BASIS_HEADER diff --git a/backends/occa/ceed-occa-ceed-object.cpp b/backends/occa/ceed-occa-ceed-object.cpp index d1db773d14..05ea6814e7 100644 --- a/backends/occa/ceed-occa-ceed-object.cpp +++ b/backends/occa/ceed-occa-ceed-object.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-ceed-object.hpp" #include "ceed-occa-context.hpp" diff --git a/backends/occa/ceed-occa-ceed-object.hpp b/backends/occa/ceed-occa-ceed-object.hpp index 6b5aaeb227..184097d83f 100644 --- a/backends/occa/ceed-occa-ceed-object.hpp +++ b/backends/occa/ceed-occa-ceed-object.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_CEEDOBJECT_HEADER #define CEED_OCCA_CEEDOBJECT_HEADER diff --git a/backends/occa/ceed-occa-context.cpp b/backends/occa/ceed-occa-context.cpp index aa0567200c..c60919c888 100644 --- a/backends/occa/ceed-occa-context.cpp +++ b/backends/occa/ceed-occa-context.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-context.hpp" diff --git a/backends/occa/ceed-occa-context.hpp b/backends/occa/ceed-occa-context.hpp index cd411c6e03..501304bcaf 100644 --- a/backends/occa/ceed-occa-context.hpp +++ b/backends/occa/ceed-occa-context.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_CONTEXT_HEADER #define CEED_OCCA_CONTEXT_HEADER diff --git a/backends/occa/ceed-occa-cpu-operator.cpp b/backends/occa/ceed-occa-cpu-operator.cpp index 46bc270b0f..92ae0a6e1d 100644 --- a/backends/occa/ceed-occa-cpu-operator.cpp +++ b/backends/occa/ceed-occa-cpu-operator.cpp @@ -1,19 +1,9 @@ -// Copyright (c) 2020, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. -#define CEED_DEBUG_COLOR 12 +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-cpu-operator.hpp" #include "ceed-occa-elem-restriction.hpp" diff --git a/backends/occa/ceed-occa-cpu-operator.hpp b/backends/occa/ceed-occa-cpu-operator.hpp index b77cb5315d..1da34be0a5 100644 --- a/backends/occa/ceed-occa-cpu-operator.hpp +++ b/backends/occa/ceed-occa-cpu-operator.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2020, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_CPU_OPERATOR_HEADER #define CEED_OCCA_CPU_OPERATOR_HEADER diff --git a/backends/occa/ceed-occa-elem-restriction.cpp b/backends/occa/ceed-occa-elem-restriction.cpp index 84df900f17..a9d844091c 100644 --- a/backends/occa/ceed-occa-elem-restriction.cpp +++ b/backends/occa/ceed-occa-elem-restriction.cpp @@ -1,20 +1,12 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include +#include #include "./ceed-occa-elem-restriction.hpp" #include "./ceed-occa-kernels.hpp" @@ -54,8 +46,6 @@ namespace ceed { } setupTransposeIndices(); - - setupKernelBuilders(); } void ElemRestriction::setupFromHostMemory(CeedCopyMode copyMode, @@ -69,7 +59,7 @@ namespace ceed { } else { const size_t bytes = entries * sizeof(CeedInt); hostIndices = (CeedInt*) ::malloc(bytes); - ::memcpy(hostIndices, indices_h, bytes); + std::memcpy(hostIndices, indices_h, bytes); } if (hostIndices) { @@ -102,7 +92,7 @@ namespace ceed { const CeedInt elementEntryCount = ceedElementCount * ceedElementSize; bool *indexIsUsed = new bool[ceedLVectorSize]; - ::memset(indexIsUsed, 0, ceedLVectorSize * sizeof(bool)); + std::memset(indexIsUsed, 0, ceedLVectorSize * sizeof(bool)); for (CeedInt i = 0; i < elementEntryCount; ++i) { indexIsUsed[hostIndices[i]] = true; @@ -119,7 +109,7 @@ namespace ceed { CeedInt *transposeDofOffsets_h = new CeedInt[dofOffsetCount]; CeedInt *transposeDofIndices_h = new CeedInt[elementEntryCount]; - ::memset(transposeDofOffsets_h, 0, dofOffsetCount * sizeof(CeedInt)); + std::memset(transposeDofOffsets_h, 0, dofOffsetCount * sizeof(CeedInt)); // Compute ids CeedInt offsetId = 0; @@ -175,23 +165,22 @@ namespace ceed { delete [] transposeDofIndices_h; } - void ElemRestriction::setupKernelBuilders() { - ::occa::properties kernelProps; - kernelProps["defines/CeedInt"] = ::occa::dtype::get().name(); - kernelProps["defines/CeedScalar"] = ::occa::dtype::get().name(); - - kernelProps["defines/COMPONENT_COUNT"] = ceedComponentCount; - kernelProps["defines/ELEMENT_SIZE"] = ceedElementSize; - kernelProps["defines/TILE_SIZE"] = 64; - kernelProps["defines/USES_INDICES"] = usesIndices(); - - applyKernelBuilder = ::occa::kernelBuilder::fromString( - occa_elem_restriction_source, "applyRestriction", kernelProps - ); - - applyTransposeKernelBuilder = ::occa::kernelBuilder::fromString( - occa_elem_restriction_source, "applyRestrictionTranspose", kernelProps - ); + void ElemRestriction::setKernelProperties() { + kernelProperties["defines/CeedInt"] = ::occa::dtype::get().name(); + kernelProperties["defines/CeedScalar"] = ::occa::dtype::get().name(); + kernelProperties["defines/COMPONENT_COUNT"] = ceedComponentCount; + kernelProperties["defines/ELEMENT_SIZE"] = ceedElementSize; + kernelProperties["defines/TILE_SIZE"] = 64; + kernelProperties["defines/USES_INDICES"] = usesIndices(); + kernelProperties["defines/USER_STRIDES"] = StrideType::USER_STRIDES; + kernelProperties["defines/NOT_STRIDED"] = StrideType::NOT_STRIDED; + kernelProperties["defines/BACKEND_STRIDES"] = StrideType::BACKEND_STRIDES; + kernelProperties["defines/STRIDE_TYPE"] = ceedStrideType; + kernelProperties["defines/NODE_COUNT"] = transposeQuadIndices.length(); + kernelProperties["defines/NODE_STRIDE"] = ceedNodeStride; + kernelProperties["defines/COMPONENT_STRIDE"] = ceedComponentStride; + kernelProperties["defines/ELEMENT_STRIDE"] = ceedElementStride; + kernelProperties["defines/UNSTRIDED_COMPONENT_STRIDE"] = ceedUnstridedComponentStride; } ElemRestriction* ElemRestriction::getElemRestriction(CeedElemRestriction r, @@ -300,42 +289,34 @@ namespace ceed { Vector &v) { const bool rIsTransposed = (rTransposeMode != CEED_NOTRANSPOSE); - ::occa::properties kernelProps; - kernelProps["defines/USER_STRIDES"] = StrideType::USER_STRIDES; - kernelProps["defines/NOT_STRIDED"] = StrideType::NOT_STRIDED; - kernelProps["defines/BACKEND_STRIDES"] = StrideType::BACKEND_STRIDES; - kernelProps["defines/STRIDE_TYPE"] = ceedStrideType; - - kernelProps["defines/NODE_COUNT"] = transposeQuadIndices.length(); - kernelProps["defines/NODE_STRIDE"] = ceedNodeStride; - kernelProps["defines/COMPONENT_STRIDE"] = ceedComponentStride; - kernelProps["defines/ELEMENT_STRIDE"] = ceedElementStride; - kernelProps["defines/UNSTRIDED_COMPONENT_STRIDE"] = ceedUnstridedComponentStride; - + // Todo: refactor if (rIsTransposed) { - ::occa::kernel applyTranspose = applyTransposeKernelBuilder.build( - getDevice(), - kernelProps - ); - - applyTranspose(ceedElementCount, - transposeQuadIndices, - transposeDofOffsets, - transposeDofIndices, - u.getConstKernelArg(), - v.getKernelArg()); + if(!restrictionTransposeKernel.isInitialized()) { + setKernelProperties(); + restrictionTransposeKernel = getDevice().buildKernelFromString( + occa_elem_restriction_source, + "applyRestrictionTranspose", + kernelProperties); + } + restrictionTransposeKernel(ceedElementCount, + transposeQuadIndices, + transposeDofOffsets, + transposeDofIndices, + u.getConstKernelArg(), + v.getKernelArg()); } else { - ::occa::kernel apply = applyKernelBuilder.build( - getDevice(), - kernelProps - ); - - apply(ceedElementCount, + if(!restrictionKernel.isInitialized()) { + setKernelProperties(); + restrictionKernel = getDevice().buildKernelFromString( + occa_elem_restriction_source, + "applyRestriction", + kernelProperties); + } + restrictionKernel(ceedElementCount, indices, u.getConstKernelArg(), v.getKernelArg()); } - return CEED_ERROR_SUCCESS; } diff --git a/backends/occa/ceed-occa-elem-restriction.hpp b/backends/occa/ceed-occa-elem-restriction.hpp index a664297ee1..f107cd3fa9 100644 --- a/backends/occa/ceed-occa-elem-restriction.hpp +++ b/backends/occa/ceed-occa-elem-restriction.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_ELEMRESTRICTION_HEADER #define CEED_OCCA_ELEMRESTRICTION_HEADER @@ -53,8 +44,9 @@ namespace ceed { ::occa::memory transposeDofOffsets; ::occa::memory transposeDofIndices; - ::occa::kernelBuilder applyKernelBuilder; - ::occa::kernelBuilder applyTransposeKernelBuilder; + ::occa::json kernelProperties; + ::occa::kernel restrictionKernel; + ::occa::kernel restrictionTransposeKernel; ElemRestriction(); @@ -74,7 +66,7 @@ namespace ceed { void setupTransposeIndices(); - void setupKernelBuilders(); + void setKernelProperties(); static ElemRestriction* getElemRestriction(CeedElemRestriction r, const bool assertValid = true); diff --git a/backends/occa/ceed-occa-gpu-operator.cpp b/backends/occa/ceed-occa-gpu-operator.cpp index b41e2b7a19..4a2c96b282 100644 --- a/backends/occa/ceed-occa-gpu-operator.cpp +++ b/backends/occa/ceed-occa-gpu-operator.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2020, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-gpu-operator.hpp" #include "ceed-occa-qfunction.hpp" diff --git a/backends/occa/ceed-occa-gpu-operator.hpp b/backends/occa/ceed-occa-gpu-operator.hpp index 77e623d1ed..bcb95f231e 100644 --- a/backends/occa/ceed-occa-gpu-operator.hpp +++ b/backends/occa/ceed-occa-gpu-operator.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2020, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_GPU_OPERATOR_HEADER #define CEED_OCCA_GPU_OPERATOR_HEADER diff --git a/backends/occa/ceed-occa-kernels.hpp b/backends/occa/ceed-occa-kernels.hpp index db9e1f3d26..13289437f0 100644 --- a/backends/occa/ceed-occa-kernels.hpp +++ b/backends/occa/ceed-occa-kernels.hpp @@ -1,23 +1,15 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_KERNELS_HEADER #define CEED_OCCA_KERNELS_HEADER #include "./kernels/elem-restriction.hpp" +#include "./kernels/set-value.hpp" #include "./kernels/simplex-basis.hpp" #include "./kernels/tensor-basis.hpp" diff --git a/backends/occa/ceed-occa-operator-args.cpp b/backends/occa/ceed-occa-operator-args.cpp index ca760c92c9..4a01853209 100644 --- a/backends/occa/ceed-occa-operator-args.cpp +++ b/backends/occa/ceed-occa-operator-args.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-operator-args.hpp" diff --git a/backends/occa/ceed-occa-operator-args.hpp b/backends/occa/ceed-occa-operator-args.hpp index 0d2d8ae7d0..0190a7266f 100644 --- a/backends/occa/ceed-occa-operator-args.hpp +++ b/backends/occa/ceed-occa-operator-args.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_OPERATORARGS_HEADER #define CEED_OCCA_OPERATORARGS_HEADER diff --git a/backends/occa/ceed-occa-operator-field.cpp b/backends/occa/ceed-occa-operator-field.cpp index 529dcd664d..95a12edc20 100644 --- a/backends/occa/ceed-occa-operator-field.cpp +++ b/backends/occa/ceed-occa-operator-field.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-operator-field.hpp" #include "ceed-occa-basis.hpp" diff --git a/backends/occa/ceed-occa-operator-field.hpp b/backends/occa/ceed-occa-operator-field.hpp index 140ddc9fb9..478e59f020 100644 --- a/backends/occa/ceed-occa-operator-field.hpp +++ b/backends/occa/ceed-occa-operator-field.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_OPERATORFIELD_HEADER #define CEED_OCCA_OPERATORFIELD_HEADER diff --git a/backends/occa/ceed-occa-operator.cpp b/backends/occa/ceed-occa-operator.cpp index a74090650a..c14b2a1198 100644 --- a/backends/occa/ceed-occa-operator.cpp +++ b/backends/occa/ceed-occa-operator.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-basis.hpp" #include "ceed-occa-elem-restriction.hpp" @@ -119,6 +110,7 @@ namespace ceed { ierr = CeedOperatorSetData(op, operator_); CeedChk(ierr); CeedOccaRegisterFunction(op, "LinearAssembleQFunction", Operator::ceedLinearAssembleQFunction); + CeedOccaRegisterFunction(op, "LinearAssembleQFunctionUpdate", Operator::ceedLinearAssembleQFunction); CeedOccaRegisterFunction(op, "LinearAssembleAddDiagonal", Operator::ceedLinearAssembleAddDiagonal); CeedOccaRegisterFunction(op, "LinearAssembleAddPointBlockDiagonal", Operator::ceedLinearAssembleAddPointBlockDiagonal); CeedOccaRegisterFunction(op, "CreateFDMElementInverse", Operator::ceedCreateFDMElementInverse); @@ -143,10 +135,15 @@ namespace ceed { return staticCeedError("(OCCA) Backend does not implement LinearAssembleQFunction"); } + int Operator::ceedLinearAssembleQFunctionUpdate(CeedOperator op) { + return staticCeedError("(OCCA) Backend does not implement LinearAssembleQFunctionUpdate"); + } + int Operator::ceedLinearAssembleAddDiagonal(CeedOperator op) { return staticCeedError("(OCCA) Backend does not implement LinearAssembleDiagonal"); } + int Operator::ceedLinearAssembleAddPointBlockDiagonal(CeedOperator op) { return staticCeedError("(OCCA) Backend does not implement LinearAssemblePointBlockDiagonal"); } diff --git a/backends/occa/ceed-occa-operator.hpp b/backends/occa/ceed-occa-operator.hpp index 295475361b..9f3ee3d132 100644 --- a/backends/occa/ceed-occa-operator.hpp +++ b/backends/occa/ceed-occa-operator.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_OPERATOR_HEADER #define CEED_OCCA_OPERATOR_HEADER @@ -70,6 +61,7 @@ namespace ceed { static int ceedCreateComposite(CeedOperator op); static int ceedLinearAssembleQFunction(CeedOperator op); + static int ceedLinearAssembleQFunctionUpdate(CeedOperator op); static int ceedLinearAssembleAddDiagonal(CeedOperator op); static int ceedLinearAssembleAddPointBlockDiagonal(CeedOperator op); static int ceedCreateFDMElementInverse(CeedOperator op); diff --git a/backends/occa/ceed-occa-qfunction-args.cpp b/backends/occa/ceed-occa-qfunction-args.cpp index e0daef5a08..cd403a98ec 100644 --- a/backends/occa/ceed-occa-qfunction-args.cpp +++ b/backends/occa/ceed-occa-qfunction-args.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-qfunction-args.hpp" diff --git a/backends/occa/ceed-occa-qfunction-args.hpp b/backends/occa/ceed-occa-qfunction-args.hpp index faf6ce13cf..0a4a02b018 100644 --- a/backends/occa/ceed-occa-qfunction-args.hpp +++ b/backends/occa/ceed-occa-qfunction-args.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_QFUNCTIONARGS_HEADER #define CEED_OCCA_QFUNCTIONARGS_HEADER diff --git a/backends/occa/ceed-occa-qfunction-field.cpp b/backends/occa/ceed-occa-qfunction-field.cpp index 6cd41b9818..8a4c520349 100644 --- a/backends/occa/ceed-occa-qfunction-field.cpp +++ b/backends/occa/ceed-occa-qfunction-field.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-qfunction-field.hpp" diff --git a/backends/occa/ceed-occa-qfunction-field.hpp b/backends/occa/ceed-occa-qfunction-field.hpp index 2194882ad0..99a777b53a 100644 --- a/backends/occa/ceed-occa-qfunction-field.hpp +++ b/backends/occa/ceed-occa-qfunction-field.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_QFUNCTIONFIELD_HEADER #define CEED_OCCA_QFUNCTIONFIELD_HEADER diff --git a/backends/occa/ceed-occa-qfunction.cpp b/backends/occa/ceed-occa-qfunction.cpp index 7d448ff9df..e6210d187d 100644 --- a/backends/occa/ceed-occa-qfunction.cpp +++ b/backends/occa/ceed-occa-qfunction.cpp @@ -1,20 +1,12 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include +#include #include "ceed-occa-qfunction.hpp" #include "ceed-occa-qfunctioncontext.hpp" @@ -22,12 +14,11 @@ namespace ceed { namespace occa { - QFunction::QFunction(const std::string &source) : + QFunction::QFunction(const std::string &source, + const std::string& function_name) : ceedIsIdentity(false) { - - const size_t colonIndex = source.find(':'); - filename = source.substr(0, colonIndex); - qFunctionName = source.substr(colonIndex + 1); + filename = source; + qFunctionName = function_name; } QFunction* QFunction::getQFunction(CeedQFunction qf, @@ -116,7 +107,7 @@ namespace ceed { // Properties only used in the QFunction kernel source props["defines/OCCA_Q"] = Q; - const std::string kernelName = "qFunctionKernel"; + const std::string kernelName = "qf_" + qFunctionName; qFunctionKernel = ( getDevice().buildKernelFromString(getKernelSource(kernelName, Q), @@ -154,8 +145,8 @@ namespace ceed { // Set and define in for the q point for (int i = 0; i < args.inputCount(); ++i) { const CeedInt fieldSize = args.getQfInput(i).size; - const std::string qIn_i = "qIn" + ::occa::toString(i); - const std::string in_i = "in" + ::occa::toString(i); + const std::string qIn_i = "qIn" + std::to_string(i); + const std::string in_i = "in" + std::to_string(i); ss << " CeedScalar " << qIn_i << "[" << fieldSize << "];" << std::endl << " in[" << i << "] = " << qIn_i << ";" << std::endl @@ -168,7 +159,7 @@ namespace ceed { // Set out for the q point for (int i = 0; i < args.outputCount(); ++i) { const CeedInt fieldSize = args.getQfOutput(i).size; - const std::string qOut_i = "qOut" + ::occa::toString(i); + const std::string qOut_i = "qOut" + std::to_string(i); ss << " CeedScalar " << qOut_i << "[" << fieldSize << "];" << std::endl << " out[" << i << "] = " << qOut_i << ";" << std::endl; @@ -179,8 +170,8 @@ namespace ceed { // Copy out for the q point for (int i = 0; i < args.outputCount(); ++i) { const CeedInt fieldSize = args.getQfOutput(i).size; - const std::string qOut_i = "qOut" + ::occa::toString(i); - const std::string out_i = "out" + ::occa::toString(i); + const std::string qOut_i = "qOut" + std::to_string(i); + const std::string out_i = "out" + std::to_string(i); ss << " for (int qi = 0; qi < " << fieldSize << "; ++qi) {" << std::endl << " " << out_i << "[q + (OCCA_Q * qi)] = " << qOut_i << "[qi];" << std::endl @@ -204,7 +195,7 @@ namespace ceed { for (CeedInt i = 0; i < args.inputCount(); i++) { Vector *u = Vector::from(U[i]); if (!u) { - return ceedError("Incorrect qFunction input field: U[" + ::occa::toString(i) + "]"); + return ceedError("Incorrect qFunction input field: U[" + std::to_string(i) + "]"); } qFunctionKernel.pushArg(u->getConstKernelArg()); } @@ -212,7 +203,7 @@ namespace ceed { for (CeedInt i = 0; i < args.outputCount(); i++) { Vector *v = Vector::from(V[i]); if (!v) { - return ceedError("Incorrect qFunction output field: V[" + ::occa::toString(i) + "]"); + return ceedError("Incorrect qFunction output field: V[" + std::to_string(i) + "]"); } qFunctionKernel.pushArg(v->getKernelArg()); } @@ -242,8 +233,10 @@ namespace ceed { ierr = CeedGetData(ceed, &context); CeedChk(ierr); char *source; ierr = CeedQFunctionGetSourcePath(qf, &source); CeedChk(ierr); + char *function_name; + ierr = CeedQFunctionGetKernelName(qf,&function_name); CeedChk(ierr); - QFunction *qFunction = new QFunction(source); + QFunction *qFunction = new QFunction(source,function_name); ierr = CeedQFunctionSetData(qf, qFunction); CeedChk(ierr); CeedOccaRegisterFunction(qf, "Apply", QFunction::ceedApply); diff --git a/backends/occa/ceed-occa-qfunction.hpp b/backends/occa/ceed-occa-qfunction.hpp index 3c9d8aac4e..0a45a7bd9d 100644 --- a/backends/occa/ceed-occa-qfunction.hpp +++ b/backends/occa/ceed-occa-qfunction.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_QFUNCTION_HEADER #define CEED_OCCA_QFUNCTION_HEADER @@ -34,7 +25,8 @@ namespace ceed { CeedQFunctionContext qFunctionContext; QFunctionArgs args; - QFunction(const std::string &source); + QFunction(const std::string &source, + const std::string &function_name); static QFunction* getQFunction(CeedQFunction qf, const bool assertValid = true); diff --git a/backends/occa/ceed-occa-qfunctioncontext.cpp b/backends/occa/ceed-occa-qfunctioncontext.cpp index 8296b5760a..be72d10ec4 100644 --- a/backends/occa/ceed-occa-qfunctioncontext.cpp +++ b/backends/occa/ceed-occa-qfunctioncontext.cpp @@ -1,18 +1,11 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed + +#include #include "ceed-occa-qfunctioncontext.hpp" @@ -103,6 +96,28 @@ namespace ceed { } } + + int QFunctionContext::hasValidData(bool* has_valid_data) const { + (*has_valid_data) = (!!hostBuffer) + || (!!currentHostBuffer ) + || (memory.isInitialized()) + || (currentMemory.isInitialized()); + return CEED_ERROR_SUCCESS; + } + + int QFunctionContext::hasBorrowedDataOfType(CeedMemType mem_type, + bool *has_borrowed_data_of_type) const { + switch (mem_type) { + case CEED_MEM_HOST: + (*has_borrowed_data_of_type) = !!currentHostBuffer; + break; + case CEED_MEM_DEVICE: + (*has_borrowed_data_of_type) = currentMemory.isInitialized(); + break; + } + return CEED_ERROR_SUCCESS; + } + int QFunctionContext::setData(CeedMemType mtype, CeedCopyMode cmode, void *data) { switch (cmode) { @@ -120,7 +135,7 @@ namespace ceed { switch (mtype) { case CEED_MEM_HOST: setCurrentHostCtxBufferIfNeeded(); - ::memcpy(currentHostBuffer, data, ctxSize); + std::memcpy(currentHostBuffer, data, ctxSize); syncState = SyncState::host; return CEED_ERROR_SUCCESS; case CEED_MEM_DEVICE: @@ -249,9 +264,12 @@ namespace ceed { Ceed ceed; ierr = CeedQFunctionContextGetCeed(ctx, &ceed); CeedChk(ierr); + CeedOccaRegisterFunction(ctx, "HasValidData", QFunctionContext::ceedHasValidData); + CeedOccaRegisterFunction(ctx, "HasBorrowedDataOfType", QFunctionContext::ceedHasBorrowedDataOfType); CeedOccaRegisterFunction(ctx, "SetData", QFunctionContext::ceedSetData); CeedOccaRegisterFunction(ctx, "TakeData", QFunctionContext::ceedTakeData); CeedOccaRegisterFunction(ctx, "GetData", QFunctionContext::ceedGetData); + CeedOccaRegisterFunction(ctx, "GetDataRead", QFunctionContext::ceedGetDataRead); CeedOccaRegisterFunction(ctx, "RestoreData", QFunctionContext::ceedRestoreData); CeedOccaRegisterFunction(ctx, "Destroy", QFunctionContext::ceedDestroy); @@ -261,6 +279,26 @@ namespace ceed { return CEED_ERROR_SUCCESS; } + int QFunctionContext::ceedHasValidData(const CeedQFunctionContext ctx, + bool *has_valid_data) { + QFunctionContext *ctx_ = QFunctionContext::from(ctx); + if (!ctx_) { + return staticCeedError("Invalid CeedQFunctionContext passed"); + } + return ctx_->hasValidData(has_valid_data); + } + + int QFunctionContext::ceedHasBorrowedDataOfType(const CeedQFunctionContext ctx, + CeedMemType mem_type, + bool *has_borrowed_data_of_type) { + QFunctionContext *ctx_ = QFunctionContext::from(ctx); + if (!ctx_) { + return staticCeedError("Invalid CeedQFunctionContext passed"); + } + return ctx_->hasBorrowedDataOfType(mem_type, + has_borrowed_data_of_type); + } + int QFunctionContext::ceedSetData(CeedQFunctionContext ctx, CeedMemType mtype, CeedCopyMode cmode, void *data) { QFunctionContext *ctx_ = QFunctionContext::from(ctx); @@ -288,6 +326,17 @@ namespace ceed { return ctx_->getData(mtype, data); } + int QFunctionContext::ceedGetDataRead(CeedQFunctionContext ctx, + CeedMemType mtype, + void *data) { + QFunctionContext *ctx_ = QFunctionContext::from(ctx); + if (!ctx_) { + return staticCeedError("Invalid CeedQFunctionContext passed"); + } + // Todo: Determine if calling getData is sufficient + return ctx_->getData(mtype, data); + } + int QFunctionContext::ceedRestoreData(CeedQFunctionContext ctx) { QFunctionContext *ctx_ = QFunctionContext::from(ctx); if (!ctx_) { diff --git a/backends/occa/ceed-occa-qfunctioncontext.hpp b/backends/occa/ceed-occa-qfunctioncontext.hpp index de5e59ada8..dbaeb5e0f4 100644 --- a/backends/occa/ceed-occa-qfunctioncontext.hpp +++ b/backends/occa/ceed-occa-qfunctioncontext.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_QFUNCTIONCONTEXT_HEADER #define CEED_OCCA_QFUNCTIONCONTEXT_HEADER @@ -67,6 +58,11 @@ namespace ceed { void freeHostCtxBuffer(); + int hasValidData(bool* has_valid_data) const; + + int hasBorrowedDataOfType(CeedMemType mem_type, + bool *has_borrowed_data_of_type) const; + int setData(CeedMemType mtype, CeedCopyMode cmode, void *data); int copyDataValues(CeedMemType mtype, void *data); @@ -89,6 +85,13 @@ namespace ceed { static int ceedCreate(CeedQFunctionContext ctx); + static int ceedHasValidData(const CeedQFunctionContext ctx, + bool *has_valid_data); + + static int ceedHasBorrowedDataOfType(const CeedQFunctionContext ctx, + CeedMemType mem_type, + bool *has_borrowed_data_of_type); + static int ceedSetData(CeedQFunctionContext ctx, CeedMemType mtype, CeedCopyMode cmode, void *data); @@ -98,6 +101,9 @@ namespace ceed { static int ceedGetData(CeedQFunctionContext ctx, CeedMemType mtype, void *data); + static int ceedGetDataRead(CeedQFunctionContext ctx, CeedMemType mtype, + void *data); + static int ceedRestoreData(CeedQFunctionContext ctx); static int ceedDestroy(CeedQFunctionContext ctx); diff --git a/backends/occa/ceed-occa-simplex-basis.cpp b/backends/occa/ceed-occa-simplex-basis.cpp index a9183f1b26..40b1d5cd31 100644 --- a/backends/occa/ceed-occa-simplex-basis.cpp +++ b/backends/occa/ceed-occa-simplex-basis.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-kernels.hpp" #include "ceed-occa-simplex-basis.hpp" @@ -38,7 +29,7 @@ namespace ceed { grad = device.malloc(P * Q * dim, grad_); qWeight = device.malloc(Q, qWeight_); - setupKernelBuilders(); + setKernelProperties(); } SimplexBasis::~SimplexBasis() {} @@ -52,7 +43,20 @@ namespace ceed { return occa_simplex_basis_cpu_function_source; } - void SimplexBasis::setupKernelBuilders() { + void SimplexBasis::setKernelProperties() { + kernelProperties["defines/CeedInt"] = ::occa::dtype::get().name(); + kernelProperties["defines/CeedScalar"] = ::occa::dtype::get().name(); + kernelProperties["defines/DIM"] = dim; + kernelProperties["defines/Q"] = Q; + kernelProperties["defines/P"] = P; + kernelProperties["defines/MAX_PQ"] = P > Q ? P : Q; + kernelProperties["defines/BASIS_COMPONENT_COUNT"] = ceedComponentCount; + if(usingGpuDevice()) { + kernelProperties["defines/ELEMENTS_PER_BLOCK"] = (Q <= 1024) ? (1024 / Q) : 1; + } + } + + ::occa::kernel SimplexBasis::buildKernel(const std::string& kernelName) { std::string kernelSource; if (usingGpuDevice()) { kernelSource = occa_simplex_basis_gpu_source; @@ -62,122 +66,77 @@ namespace ceed { kernelSource += occa_simplex_basis_cpu_kernel_source; } - ::occa::properties kernelProps; - kernelProps["defines/CeedInt"] = ::occa::dtype::get().name(); - kernelProps["defines/CeedScalar"] = ::occa::dtype::get().name(); - kernelProps["defines/DIM"] = dim; - kernelProps["defines/Q"] = Q; - kernelProps["defines/P"] = P; - kernelProps["defines/MAX_PQ"] = P > Q ? P : Q; - kernelProps["defines/BASIS_COMPONENT_COUNT"] = ceedComponentCount; - - interpKernelBuilder = ::occa::kernelBuilder::fromString( - kernelSource, "interp", kernelProps - ); - gradKernelBuilder = ::occa::kernelBuilder::fromString( - kernelSource, "grad" , kernelProps - ); - weightKernelBuilder = ::occa::kernelBuilder::fromString( - kernelSource, "weight", kernelProps - ); + return getDevice().buildKernelFromString(kernelSource, + kernelName, + kernelProperties); } int SimplexBasis::applyInterp(const CeedInt elementCount, const bool transpose, Vector &U, Vector &V) { - ::occa::kernel interpKernel = ( - usingGpuDevice() - ? getGpuInterpKernel(transpose) - : getCpuInterpKernel(transpose) - ); - - interpKernel(elementCount, - interp, - U.getConstKernelArg(), - V.getKernelArg()); - + if(transpose) { + if(!interpTKernel.isInitialized()) { + kernelProperties["defines/TRANSPOSE"] = transpose; + interpTKernel = buildKernel("interp"); + } + + interpTKernel(elementCount, + interp, + U.getConstKernelArg(), + V.getKernelArg()); + } else { + if(!interpKernel.isInitialized()) { + kernelProperties["defines/TRANSPOSE"] = transpose; + interpKernel = buildKernel("interp"); + } + + interpKernel(elementCount, + interp, + U.getConstKernelArg(), + V.getKernelArg()); + } return CEED_ERROR_SUCCESS; } - ::occa::kernel SimplexBasis::getCpuInterpKernel(const bool transpose) { - return buildCpuEvalKernel(interpKernelBuilder, - transpose); - } - - ::occa::kernel SimplexBasis::getGpuInterpKernel(const bool transpose) { - return buildGpuEvalKernel(interpKernelBuilder, - transpose); - } - int SimplexBasis::applyGrad(const CeedInt elementCount, const bool transpose, Vector &U, Vector &V) { - ::occa::kernel gradKernel = ( - usingGpuDevice() - ? getGpuGradKernel(transpose) - : getCpuGradKernel(transpose) - ); + if(transpose) { + if(!gradTKernel.isInitialized()) { + kernelProperties["defines/TRANSPOSE"] = transpose; + gradTKernel = buildKernel("grad"); + } - gradKernel(elementCount, - grad, - U.getConstKernelArg(), - V.getKernelArg()); + gradTKernel(elementCount, + grad, + U.getConstKernelArg(), + V.getKernelArg()); + } else { + if(!gradKernel.isInitialized()) { + kernelProperties["defines/TRANSPOSE"] = transpose; + gradKernel = buildKernel("grad"); + } + gradKernel(elementCount, + grad, + U.getConstKernelArg(), + V.getKernelArg()); + } return CEED_ERROR_SUCCESS; } - ::occa::kernel SimplexBasis::getCpuGradKernel(const bool transpose) { - return buildCpuEvalKernel(gradKernelBuilder, - transpose); - } - - ::occa::kernel SimplexBasis::getGpuGradKernel(const bool transpose) { - return buildGpuEvalKernel(gradKernelBuilder, - transpose); - } - int SimplexBasis::applyWeight(const CeedInt elementCount, Vector &W) { - ::occa::kernel weightKernel = ( - usingGpuDevice() - ? getGpuWeightKernel() - : getCpuWeightKernel() - ); - + if(!weightKernel.isInitialized()) { + weightKernel = buildKernel("weight"); + } weightKernel(elementCount, qWeight, W.getKernelArg()); return CEED_ERROR_SUCCESS; } - ::occa::kernel SimplexBasis::getCpuWeightKernel() { - return buildCpuEvalKernel(weightKernelBuilder, - false); - } - - ::occa::kernel SimplexBasis::getGpuWeightKernel() { - return buildGpuEvalKernel(weightKernelBuilder, - false); - } - - ::occa::kernel SimplexBasis::buildCpuEvalKernel(::occa::kernelBuilder &kernelBuilder, - const bool transpose) { - ::occa::properties kernelProps; - kernelProps["defines/TRANSPOSE"] = transpose; - - return kernelBuilder.build(getDevice(), kernelProps); - } - - ::occa::kernel SimplexBasis::buildGpuEvalKernel(::occa::kernelBuilder &kernelBuilder, - const bool transpose) { - ::occa::properties kernelProps; - kernelProps["defines/TRANSPOSE"] = transpose; - kernelProps["defines/ELEMENTS_PER_BLOCK"] = Q <= 1024 ? (1024 / Q) : 1; - - return kernelBuilder.build(getDevice(), kernelProps); - } - int SimplexBasis::apply(const CeedInt elementCount, CeedTransposeMode tmode, CeedEvalMode emode, diff --git a/backends/occa/ceed-occa-simplex-basis.hpp b/backends/occa/ceed-occa-simplex-basis.hpp index 94a766cbd4..1f8d141bde 100644 --- a/backends/occa/ceed-occa-simplex-basis.hpp +++ b/backends/occa/ceed-occa-simplex-basis.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_SIMPLEXBASIS_HEADER #define CEED_OCCA_SIMPLEXBASIS_HEADER @@ -26,9 +17,13 @@ namespace ceed { ::occa::memory interp; ::occa::memory grad; ::occa::memory qWeight; - ::occa::kernelBuilder interpKernelBuilder; - ::occa::kernelBuilder gradKernelBuilder; - ::occa::kernelBuilder weightKernelBuilder; + + ::occa::json kernelProperties; + ::occa::kernel interpKernel; + ::occa::kernel interpTKernel; + ::occa::kernel gradKernel; + ::occa::kernel gradTKernel; + ::occa::kernel weightKernel; SimplexBasis(CeedBasis basis, CeedInt dim, @@ -44,36 +39,25 @@ namespace ceed { const char* getFunctionSource() const; - void setupKernelBuilders(); + void setKernelProperties(); + + std::string getKernelSource() const; + + ::occa::kernel buildKernel(const std::string& kernelName); int applyInterp(const CeedInt elementCount, const bool transpose, Vector &U, Vector &V); - ::occa::kernel getCpuInterpKernel(const bool transpose); - ::occa::kernel getGpuInterpKernel(const bool transpose); - int applyGrad(const CeedInt elementCount, const bool transpose, Vector &U, Vector &V); - ::occa::kernel getCpuGradKernel(const bool transpose); - ::occa::kernel getGpuGradKernel(const bool transpose); - int applyWeight(const CeedInt elementCount, Vector &W); - ::occa::kernel getCpuWeightKernel(); - ::occa::kernel getGpuWeightKernel(); - - ::occa::kernel buildCpuEvalKernel(::occa::kernelBuilder &kernelBuilder, - const bool transpose); - - ::occa::kernel buildGpuEvalKernel(::occa::kernelBuilder &kernelBuilder, - const bool transpose); - int apply(const CeedInt elementCount, CeedTransposeMode tmode, CeedEvalMode emode, diff --git a/backends/occa/ceed-occa-tensor-basis.cpp b/backends/occa/ceed-occa-tensor-basis.cpp index 20e1d21f95..22963bf812 100644 --- a/backends/occa/ceed-occa-tensor-basis.cpp +++ b/backends/occa/ceed-occa-tensor-basis.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "ceed-occa-kernels.hpp" #include "ceed-occa-tensor-basis.hpp" @@ -45,7 +36,7 @@ namespace ceed { grad1D = device.malloc(P1D * Q1D, grad1D_); qWeight1D = device.malloc(Q1D, qWeight1D_); - setupKernelBuilders(); + setKernelProperties(); } TensorBasis::~TensorBasis() {} @@ -54,6 +45,17 @@ namespace ceed { return true; } + void TensorBasis::setKernelProperties() { + kernelProperties["defines/CeedInt"] = ::occa::dtype::get().name(); + kernelProperties["defines/CeedScalar"] = ::occa::dtype::get().name(); + kernelProperties["defines/Q1D"] = Q1D; + kernelProperties["defines/P1D"] = P1D; + kernelProperties["defines/BASIS_COMPONENT_COUNT"] = ceedComponentCount; + if(usingGpuDevice()) { + kernelProperties["defines/MAX_PQ"] = (Q1D > P1D) ? Q1D : P1D; + } + } + const char* TensorBasis::getFunctionSource() const { // TODO: Add gpu function sources when split const char *cpuFunctionSources[3] = { @@ -64,7 +66,7 @@ namespace ceed { return cpuFunctionSources[dim - 1]; } - void TensorBasis::setupKernelBuilders() { + std::string TensorBasis::getKernelSource() const { const char *cpuFunctionSources[3] = { occa_tensor_basis_1d_cpu_function_source, occa_tensor_basis_2d_cpu_function_source, @@ -89,49 +91,45 @@ namespace ceed { kernelSource += '\n'; kernelSource += cpuKernelSources[dim - 1]; } + return kernelSource; + } - ::occa::properties kernelProps; - kernelProps["defines/CeedInt"] = ::occa::dtype::get().name(); - kernelProps["defines/CeedScalar"] = ::occa::dtype::get().name(); - kernelProps["defines/Q1D"] = Q1D; - kernelProps["defines/P1D"] = P1D; - kernelProps["defines/BASIS_COMPONENT_COUNT"] = ceedComponentCount; - - interpKernelBuilder = ::occa::kernelBuilder::fromString( - kernelSource, "interp", kernelProps - ); - gradKernelBuilder = ::occa::kernelBuilder::fromString( - kernelSource, "grad" , kernelProps - ); - weightKernelBuilder = ::occa::kernelBuilder::fromString( - kernelSource, "weight", kernelProps - ); + ::occa::kernel TensorBasis::buildKernel(const std::string& kernelName) { + std::string kernelSource = getKernelSource(); + return getDevice().buildKernelFromString(kernelSource, + kernelName, + kernelProperties); } int TensorBasis::applyInterp(const CeedInt elementCount, const bool transpose, Vector &U, Vector &V) { - ::occa::kernel interp = ( - usingGpuDevice() - ? getGpuInterpKernel(transpose) - : getCpuInterpKernel(transpose) - ); - - interp(elementCount, - interp1D, - U.getConstKernelArg(), - V.getKernelArg()); - + if(transpose) { + if(!interpTKernel.isInitialized()) { + kernelProperties["defines/TRANSPOSE"] = transpose; + kernelProperties["defines/ELEMENTS_PER_BLOCK"] = elementsPerBlockInterp(); + interpTKernel = buildKernel("interp"); + } + interpTKernel(elementCount, + interp1D, + U.getConstKernelArg(), + V.getKernelArg()); + } else { + if(!interpKernel.isInitialized()) { + kernelProperties["defines/TRANSPOSE"] = transpose; + kernelProperties["defines/ELEMENTS_PER_BLOCK"] = elementsPerBlockInterp(); + interpKernel = buildKernel("interp"); + } + interpKernel(elementCount, + interp1D, + U.getConstKernelArg(), + V.getKernelArg()); + } return CEED_ERROR_SUCCESS; } - ::occa::kernel TensorBasis::getCpuInterpKernel(const bool transpose) { - return buildCpuEvalKernel(interpKernelBuilder, - transpose); - } - - ::occa::kernel TensorBasis::getGpuInterpKernel(const bool transpose) { + int TensorBasis::elementsPerBlockInterp() const { int elementsPerBlock; if (dim == 1) { elementsPerBlock = 32; @@ -145,36 +143,41 @@ namespace ceed { } else { elementsPerBlock = 1; } - - return buildGpuEvalKernel(interpKernelBuilder, - transpose, - elementsPerBlock); + return elementsPerBlock; } int TensorBasis::applyGrad(const CeedInt elementCount, const bool transpose, Vector &U, Vector &V) { - ::occa::kernel grad = ( - usingGpuDevice() - ? getGpuGradKernel(transpose) - : getCpuGradKernel(transpose) - ); - - grad(elementCount, - interp1D, grad1D, - U.getConstKernelArg(), - V.getKernelArg()); - + + if(transpose) { + if(!gradTKernel.isInitialized()) { + kernelProperties["defines/TRANSPOSE"] = transpose; + kernelProperties["defines/ELEMENTS_PER_BLOCK"] = elementsPerBlockGrad(); + gradTKernel = buildKernel("grad"); + } + gradTKernel(elementCount, + interp1D, + grad1D, + U.getConstKernelArg(), + V.getKernelArg()); + } else { + if(!gradKernel.isInitialized()) { + kernelProperties["defines/TRANSPOSE"] = transpose; + kernelProperties["defines/ELEMENTS_PER_BLOCK"] = elementsPerBlockGrad(); + gradKernel = buildKernel("grad"); + } + gradKernel(elementCount, + interp1D, + grad1D, + U.getConstKernelArg(), + V.getKernelArg()); + } return CEED_ERROR_SUCCESS; } - ::occa::kernel TensorBasis::getCpuGradKernel(const bool transpose) { - return buildCpuEvalKernel(gradKernelBuilder, - transpose); - } - - ::occa::kernel TensorBasis::getGpuGradKernel(const bool transpose) { + int TensorBasis::elementsPerBlockGrad() const { int elementsPerBlock; if (dim == 1) { elementsPerBlock = 32; @@ -188,31 +191,21 @@ namespace ceed { } else { elementsPerBlock = 1; } - - return buildGpuEvalKernel(gradKernelBuilder, - transpose, - elementsPerBlock); + return elementsPerBlock; } int TensorBasis::applyWeight(const CeedInt elementCount, Vector &W) { - ::occa::kernel weight = ( - usingGpuDevice() - ? getGpuWeightKernel() - : getCpuWeightKernel() - ); - - weight(elementCount, qWeight1D, W.getKernelArg()); + if(!weightKernel.isInitialized()) { + kernelProperties["defines/ELEMENTS_PER_BLOCK"] = elementsPerBlockWeight(); + weightKernel = buildKernel("weight"); + } + weightKernel(elementCount, qWeight1D, W.getKernelArg()); return CEED_ERROR_SUCCESS; } - ::occa::kernel TensorBasis::getCpuWeightKernel() { - return buildCpuEvalKernel(weightKernelBuilder, - false); - } - - ::occa::kernel TensorBasis::getGpuWeightKernel() { + int TensorBasis::elementsPerBlockWeight() const { int elementsPerBlock; if (dim == 1) { elementsPerBlock = 32 / Q1D; @@ -225,30 +218,7 @@ namespace ceed { } else { elementsPerBlock = Q1D; } - - return buildGpuEvalKernel(weightKernelBuilder, - false, - elementsPerBlock); - } - - ::occa::kernel TensorBasis::buildCpuEvalKernel(::occa::kernelBuilder &kernelBuilder, - const bool transpose) { - ::occa::properties kernelProps; - kernelProps["defines/TRANSPOSE"] = transpose; - - return kernelBuilder.build(getDevice(), kernelProps); - } - - ::occa::kernel TensorBasis::buildGpuEvalKernel(::occa::kernelBuilder &kernelBuilder, - const bool transpose, - const int elementsPerBlock) { - - ::occa::properties kernelProps; - kernelProps["defines/TRANSPOSE"] = transpose; - kernelProps["defines/MAX_PQ"] = Q1D > P1D ? Q1D : P1D; - kernelProps["defines/ELEMENTS_PER_BLOCK"] = elementsPerBlock; - - return kernelBuilder.build(getDevice(), kernelProps); + return elementsPerBlock; } int TensorBasis::apply(const CeedInt elementCount, diff --git a/backends/occa/ceed-occa-tensor-basis.hpp b/backends/occa/ceed-occa-tensor-basis.hpp index 5a9195d074..8b024deb9f 100644 --- a/backends/occa/ceed-occa-tensor-basis.hpp +++ b/backends/occa/ceed-occa-tensor-basis.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_TENSORBASIS_HEADER #define CEED_OCCA_TENSORBASIS_HEADER @@ -28,9 +19,13 @@ namespace ceed { ::occa::memory interp1D; ::occa::memory grad1D; ::occa::memory qWeight1D; - ::occa::kernelBuilder interpKernelBuilder; - ::occa::kernelBuilder gradKernelBuilder; - ::occa::kernelBuilder weightKernelBuilder; + + ::occa::json kernelProperties; + ::occa::kernel interpKernel; + ::occa::kernel interpTKernel; + ::occa::kernel gradKernel; + ::occa::kernel gradTKernel; + ::occa::kernel weightKernel; TensorBasis(CeedBasis basis, CeedInt dim_, @@ -46,37 +41,29 @@ namespace ceed { const char* getFunctionSource() const; - void setupKernelBuilders(); + std::string getKernelSource() const; + + void setKernelProperties(); + + int elementsPerBlockInterp() const; + int elementsPerBlockGrad() const; + int elementsPerBlockWeight() const; + + ::occa::kernel buildKernel(const std::string& kernelName); int applyInterp(const CeedInt elementCount, const bool transpose, Vector &U, Vector &V); - ::occa::kernel getCpuInterpKernel(const bool transpose); - ::occa::kernel getGpuInterpKernel(const bool transpose); - int applyGrad(const CeedInt elementCount, const bool transpose, Vector &U, Vector &V); - ::occa::kernel getCpuGradKernel(const bool transpose); - ::occa::kernel getGpuGradKernel(const bool transpose); - int applyWeight(const CeedInt elementCount, Vector &W); - ::occa::kernel getCpuWeightKernel(); - ::occa::kernel getGpuWeightKernel(); - - ::occa::kernel buildCpuEvalKernel(::occa::kernelBuilder &kernelBuilder, - const bool transpose); - - ::occa::kernel buildGpuEvalKernel(::occa::kernelBuilder &kernelBuilder, - const bool transpose, - const int elementsPerBlock); - int apply(const CeedInt elementCount, CeedTransposeMode tmode, CeedEvalMode emode, diff --git a/backends/occa/ceed-occa-types.hpp b/backends/occa/ceed-occa-types.hpp index 391575418a..f2661e1909 100644 --- a/backends/occa/ceed-occa-types.hpp +++ b/backends/occa/ceed-occa-types.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_TYPES_HEADER #define CEED_OCCA_TYPES_HEADER diff --git a/backends/occa/ceed-occa-vector.cpp b/backends/occa/ceed-occa-vector.cpp index f40be0358a..6f2982edaf 100644 --- a/backends/occa/ceed-occa-vector.cpp +++ b/backends/occa/ceed-occa-vector.cpp @@ -1,19 +1,13 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed +#include + +#include "ceed-occa-kernels.hpp" #include "ceed-occa-vector.hpp" namespace ceed { @@ -30,6 +24,27 @@ namespace ceed { freeHostBuffer(); } + int Vector::hasValidArray(bool* has_valid_array) { + (*has_valid_array) = (!!hostBuffer) + || (!!currentHostBuffer) + || (memory.isInitialized()) + || (currentMemory.isInitialized()); + return CEED_ERROR_SUCCESS; + } + + int Vector::hasBorrowedArrayOfType(CeedMemType mem_type, + bool *has_borrowed_array_of_type) { + switch (mem_type) { + case CEED_MEM_HOST: + (*has_borrowed_array_of_type) = !!currentHostBuffer; + break; + case CEED_MEM_DEVICE: + (*has_borrowed_array_of_type) = currentMemory.isInitialized(); + break; + } + return CEED_ERROR_SUCCESS; + } + Vector* Vector::getVector(CeedVector vec, const bool assertValid) { if (!vec || vec == CEED_VECTOR_NONE) { @@ -107,7 +122,19 @@ namespace ceed { // Prioritize keeping data in the device if (syncState & SyncState::device) { setCurrentMemoryIfNeeded(); - ::occa::linalg::operator_eq(currentMemory, value); + if(!setValueKernel.isInitialized()) { + ::occa::json kernelProperties; + CeedInt constexpr block_size{256}; + kernelProperties["defines/CeedInt"] = ::occa::dtype::get().name(); + kernelProperties["defines/CeedScalar"] = ::occa::dtype::get().name(); + kernelProperties["defines/BLOCK_SIZE"] = block_size; + + std::string kernelSource = occa_set_value_source; + setValueKernel = getDevice().buildKernelFromString( + kernelSource,"setValue",kernelProperties + ); + setValueKernel(currentMemory,value,length); + } syncState = SyncState::device; } else { setCurrentHostBufferIfNeeded(); @@ -167,7 +194,7 @@ namespace ceed { case CEED_MEM_HOST: setCurrentHostBufferIfNeeded(); if (array) { - ::memcpy(currentHostBuffer, array, length * sizeof(CeedScalar)); + std::memcpy(currentHostBuffer, array, length * sizeof(CeedScalar)); } syncState = SyncState::host; return CEED_ERROR_SUCCESS; @@ -257,6 +284,22 @@ namespace ceed { return error; } + int Vector::getWriteOnlyArray(CeedMemType mtype, + CeedScalar **array) { + // const bool willBeFullySynced = ( + // (syncState == SyncState::device && mtype == CEED_MEM_HOST) || + // (syncState == SyncState::host && mtype == CEED_MEM_DEVICE) + // ); + + const int error = getArray(mtype, const_cast(array)); + // // Take advantage the vector will be fully synced + // if (!error && willBeFullySynced) { + // syncState = SyncState::all; + // } + + return error; + } + int Vector::restoreArray(CeedScalar **array) { return CEED_ERROR_SUCCESS; } @@ -345,11 +388,14 @@ namespace ceed { Ceed ceed; ierr = CeedVectorGetCeed(vec, &ceed); CeedChk(ierr); + CeedOccaRegisterFunction(vec, "HasValidArray", Vector::ceedHasValidArray); + CeedOccaRegisterFunction(vec, "HasBorrowedArrayOfType",Vector::ceedHasBorrowedArrayOfType); CeedOccaRegisterFunction(vec, "SetValue", Vector::ceedSetValue); CeedOccaRegisterFunction(vec, "SetArray", Vector::ceedSetArray); CeedOccaRegisterFunction(vec, "TakeArray", Vector::ceedTakeArray); CeedOccaRegisterFunction(vec, "GetArray", Vector::ceedGetArray); CeedOccaRegisterFunction(vec, "GetArrayRead", Vector::ceedGetArrayRead); + CeedOccaRegisterFunction(vec, "GetArrayWrite", Vector::ceedGetArrayWrite); CeedOccaRegisterFunction(vec, "RestoreArray", Vector::ceedRestoreArray); CeedOccaRegisterFunction(vec, "RestoreArrayRead", Vector::ceedRestoreArrayRead); CeedOccaRegisterFunction(vec, "Destroy", Vector::ceedDestroy); @@ -360,6 +406,24 @@ namespace ceed { return CEED_ERROR_SUCCESS; } + int Vector::ceedHasValidArray(CeedVector vec, bool* has_valid_array) { + Vector *vector = Vector::from(vec); + if (!vector) { + return staticCeedError("Invalid CeedVector passed"); + } + return vector->hasValidArray(has_valid_array); + } + + int Vector::ceedHasBorrowedArrayOfType(CeedVector vec, + CeedMemType mem_type, + bool *has_borrowed_array_of_type) { + Vector *vector = Vector::from(vec); + if (!vector) { + return staticCeedError("Invalid CeedVector passed"); + } + return vector->hasBorrowedArrayOfType(mem_type,has_borrowed_array_of_type); + } + int Vector::ceedSetValue(CeedVector vec, CeedScalar value) { Vector *vector = Vector::from(vec); if (!vector) { @@ -403,6 +467,15 @@ namespace ceed { return vector->getReadOnlyArray(mtype, array); } + int Vector::ceedGetArrayWrite(CeedVector vec, CeedMemType mtype, + CeedScalar **array) { + Vector *vector = Vector::from(vec); + if (!vector) { + return staticCeedError("Invalid CeedVector passed"); + } + return vector->getWriteOnlyArray(mtype, array); + } + int Vector::ceedRestoreArray(CeedVector vec, CeedScalar **array) { Vector *vector = Vector::from(vec); if (!vector) { diff --git a/backends/occa/ceed-occa-vector.hpp b/backends/occa/ceed-occa-vector.hpp index 94d2ee5ed3..eb90c7d34f 100644 --- a/backends/occa/ceed-occa-vector.hpp +++ b/backends/occa/ceed-occa-vector.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_VECTOR_HEADER #define CEED_OCCA_VECTOR_HEADER @@ -25,7 +16,8 @@ namespace ceed { ::occa::memory arrayToMemory(const TM *array) { if (array) { ::occa::memory mem((::occa::modeMemory_t*) array); - return mem.as(::occa::dtype::get()); + mem.setDtype(::occa::dtype::get()); + return mem; } return ::occa::null; } @@ -43,6 +35,8 @@ namespace ceed { CeedSize hostBufferLength; CeedScalar *hostBuffer; + ::occa::kernel setValueKernel; + // Current resources ::occa::memory currentMemory; CeedScalar *currentHostBuffer; @@ -54,6 +48,10 @@ namespace ceed { ~Vector(); + int hasValidArray(bool* has_valid_array); + + int hasBorrowedArrayOfType(CeedMemType mem_type,bool *has_borrowed_array_of_type); + static Vector* getVector(CeedVector vec, const bool assertValid = true); @@ -91,6 +89,9 @@ namespace ceed { int getReadOnlyArray(CeedMemType mtype, CeedScalar **array); + + int getWriteOnlyArray(CeedMemType mtype, + CeedScalar **array); int restoreArray(CeedScalar **array); @@ -108,6 +109,12 @@ namespace ceed { static int registerCeedFunction(Ceed ceed, CeedVector vec, const char *fname, ceed::occa::ceedFunction f); + static int ceedHasValidArray(CeedVector vec, bool* has_valid_array); + + static int ceedHasBorrowedArrayOfType(CeedVector vec, + CeedMemType mem_type, + bool *has_borrowed_array_of_type); + static int ceedCreate(CeedSize length, CeedVector vec); static int ceedSetValue(CeedVector vec, CeedScalar value); @@ -123,6 +130,9 @@ namespace ceed { static int ceedGetArrayRead(CeedVector vec, CeedMemType mtype, CeedScalar **array); + static int ceedGetArrayWrite(CeedVector vec, CeedMemType mtype, + CeedScalar **array); + static int ceedRestoreArray(CeedVector vec, CeedScalar **array); static int ceedRestoreArrayRead(CeedVector vec, CeedScalar **array); diff --git a/backends/occa/ceed-occa.cpp b/backends/occa/ceed-occa.cpp index e5b4abbfef..c9161c679b 100644 --- a/backends/occa/ceed-occa.cpp +++ b/backends/occa/ceed-occa.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #warning "libCEED OCCA backend is experimental; for best performance, use device native backends" @@ -57,11 +48,12 @@ namespace ceed { if (::occa::modeIsEnabled("HIP")) { return "HIP"; } - /* OpenCL not fully supported in OCCA + if (::occa::modeIsEnabled("dpcpp")) { + return "dpcpp"; + } if (::occa::modeIsEnabled("OpenCL")) { return "OpenCL"; } - */ // Metal doesn't support doubles } @@ -85,12 +77,14 @@ namespace ceed { mode = "HIP"; return CEED_ERROR_SUCCESS; } - /* OpenCL not fully supported in OCCA + if (match == "dpcpp") { + mode = "dpcpp"; + return CEED_ERROR_SUCCESS; + } if (match == "opencl") { mode = "OpenCL"; return CEED_ERROR_SUCCESS; } - */ if (match == "openmp") { mode = "OpenMP"; return CEED_ERROR_SUCCESS; @@ -151,12 +145,14 @@ namespace ceed { match = "hip"; return CEED_ERROR_SUCCESS; } - /* + if (resource == "/gpu/dpcpp/occa"){ + match = "dpcpp"; + return CEED_ERROR_SUCCESS; + } if (resource == "/gpu/opencl/occa"){ match = "opencl"; return CEED_ERROR_SUCCESS; } - */ if (resource == "/cpu/openmp/occa"){ match = "openmp"; return CEED_ERROR_SUCCESS; @@ -220,26 +216,25 @@ namespace ceed { mode = (std::string) deviceProps["mode"]; } else { mode = defaultMode; - deviceProps["mode"] = mode; + deviceProps.set("mode",mode); } // Set default device id - // Note: OpenCL not fully supported in OCCA if ((mode == "CUDA") - || (mode == "HIP")) { + || (mode == "HIP") + || (mode == "dpcpp") + || (mode == "OpenCL")) { if (!deviceProps.has("device_id")) { deviceProps["device_id"] = 0; } } // Set default platform id - /* OpenCL not fully supported in OCCA - if (mode == "OpenCL") { + if ((mode=="dpcpp") || (mode == "OpenCL")){ if (!deviceProps.has("platform_id")) { deviceProps["platform_id"] = 0; } } - */ } static int initCeed(const char *c_resource, Ceed ceed) { @@ -327,11 +322,15 @@ namespace ceed { try { ierr = ceed::occa::initCeed(resource, ceed); CeedChkBackend(ierr); + } catch (const ::occa::exception &e) { + CeedHandleOccaException(e); + } + try { ierr = ceed::occa::registerMethods(ceed); CeedChkBackend(ierr); - } catch (::occa::exception &exc) { - CeedHandleOccaException(exc); } - + catch (const ::occa::exception &e) { + CeedHandleOccaException(e); + } return CEED_ERROR_SUCCESS; } } @@ -340,16 +339,14 @@ namespace ceed { CEED_INTERN int CeedRegister_Occa(void) { int ierr; // General mode - ierr = CeedRegister("/*/occa", ceed::occa::registerBackend, 260); CeedChkBackend(ierr); + ierr = CeedRegister("/*/occa", ceed::occa::registerBackend, 270); CeedChkBackend(ierr); // CPU Modes - ierr = CeedRegister("/cpu/self/occa", ceed::occa::registerBackend, 250); CeedChkBackend(ierr); - ierr = CeedRegister("/cpu/openmp/occa", ceed::occa::registerBackend, 240); CeedChkBackend(ierr); - // OpenCL Mode - /* OpenCL not fully supported in OCCA - ierr = CeedRegister("/gpu/opencl/occa", ceed::occa::registerBackend, 230); CeedChkBackend(ierr); - */ + ierr = CeedRegister("/cpu/self/occa",ceed::occa::registerBackend, 260); CeedChkBackend(ierr); + ierr = CeedRegister("/cpu/openmp/occa",ceed::occa::registerBackend, 250); CeedChkBackend(ierr); // GPU Modes - ierr = CeedRegister("/gpu/hip/occa", ceed::occa::registerBackend, 220); CeedChkBackend(ierr); - ierr = CeedRegister("/gpu/cuda/occa", ceed::occa::registerBackend, 210); CeedChkBackend(ierr); + ierr = CeedRegister("/gpu/dpcpp/occa",ceed::occa::registerBackend, 240); CeedChkBackend(ierr); + ierr = CeedRegister("/gpu/opencl/occa",ceed::occa::registerBackend, 230); CeedChkBackend(ierr); + ierr = CeedRegister("/gpu/hip/occa",ceed::occa::registerBackend, 220); CeedChkBackend(ierr); + ierr = CeedRegister("/gpu/cuda/occa",ceed::occa::registerBackend, 210); CeedChkBackend(ierr); return CEED_ERROR_SUCCESS; } diff --git a/backends/occa/kernels/elem-restriction.cpp b/backends/occa/kernels/elem-restriction.cpp index 1da44105ee..05e89b8280 100644 --- a/backends/occa/kernels/elem-restriction.cpp +++ b/backends/occa/kernels/elem-restriction.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "./kernel-defines.hpp" diff --git a/backends/occa/kernels/elem-restriction.hpp b/backends/occa/kernels/elem-restriction.hpp index 01273f8f4c..581d6191d8 100644 --- a/backends/occa/kernels/elem-restriction.hpp +++ b/backends/occa/kernels/elem-restriction.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_KERNELS_ELEMRESTRICTION_HEADER #define CEED_OCCA_KERNELS_ELEMRESTRICTION_HEADER diff --git a/backends/occa/kernels/kernel-defines.hpp b/backends/occa/kernels/kernel-defines.hpp index 046fc75506..1877e167ac 100644 --- a/backends/occa/kernels/kernel-defines.hpp +++ b/backends/occa/kernels/kernel-defines.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_KERNELS_KERNELDEFINES_HEADER #define CEED_OCCA_KERNELS_KERNELDEFINES_HEADER diff --git a/backends/occa/kernels/set-value.cpp b/backends/occa/kernels/set-value.cpp new file mode 100644 index 0000000000..113d190ccd --- /dev/null +++ b/backends/occa/kernels/set-value.cpp @@ -0,0 +1,26 @@ +// Copyright (c) 2017-2022, 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 + +#include "./kernel-defines.hpp" + +// Expects the following types to be defined: +// - CeedInt +// - CeedScalar +// +// Expects the following constants to be defined: +// - BLOCK_SIZE : CeedInt + +const char *occa_set_value_source = STRINGIFY_SOURCE( + + @kernel + void setValue(CeedScalar* ptr,const CeedScalar value,const CeedInt count) { + @tile(BLOCK_SIZE,@outer,@inner) + for(CeedInt i=0; i < count; ++i) { + ptr[i] = value; + } + } +); diff --git a/backends/occa/kernels/set-value.hpp b/backends/occa/kernels/set-value.hpp new file mode 100644 index 0000000000..cd73e21bc9 --- /dev/null +++ b/backends/occa/kernels/set-value.hpp @@ -0,0 +1,20 @@ +// Copyright (c) 2017-2022, 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 + +#ifndef CEED_OCCA_KERNELS_SETVALUE_HEADER +#define CEED_OCCA_KERNELS_SETVALUE_HEADER + +// Expects the following types to be defined: +// - CeedInt +// - CeedScalar +// +// Expects the following constants to be defined: +// - BLOCK_SIZE : CeedInt + +extern const char *occa_set_value_source; + +#endif \ No newline at end of file diff --git a/backends/occa/kernels/simplex-basis.hpp b/backends/occa/kernels/simplex-basis.hpp index 314b725ff9..95a18161ac 100644 --- a/backends/occa/kernels/simplex-basis.hpp +++ b/backends/occa/kernels/simplex-basis.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_KERNELS_SIMPLEXBASIS_HEADER #define CEED_OCCA_KERNELS_SIMPLEXBASIS_HEADER diff --git a/backends/occa/kernels/simplex-basis/cpu-simplex-basis.cpp b/backends/occa/kernels/simplex-basis/cpu-simplex-basis.cpp index 5f328bda23..d541580f8a 100644 --- a/backends/occa/kernels/simplex-basis/cpu-simplex-basis.cpp +++ b/backends/occa/kernels/simplex-basis/cpu-simplex-basis.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "../kernel-defines.hpp" diff --git a/backends/occa/kernels/simplex-basis/gpu-simplex-basis.cpp b/backends/occa/kernels/simplex-basis/gpu-simplex-basis.cpp index 469a21e167..95ac8ce445 100644 --- a/backends/occa/kernels/simplex-basis/gpu-simplex-basis.cpp +++ b/backends/occa/kernels/simplex-basis/gpu-simplex-basis.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "../kernel-defines.hpp" diff --git a/backends/occa/kernels/tensor-basis.hpp b/backends/occa/kernels/tensor-basis.hpp index b21182ee2b..16f505bb27 100644 --- a/backends/occa/kernels/tensor-basis.hpp +++ b/backends/occa/kernels/tensor-basis.hpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #ifndef CEED_OCCA_KERNELS_TENSORBASIS_HEADER #define CEED_OCCA_KERNELS_TENSORBASIS_HEADER diff --git a/backends/occa/kernels/tensor-basis/cpu/tensor-basis-1d.cpp b/backends/occa/kernels/tensor-basis/cpu/tensor-basis-1d.cpp index 89d62b0506..1a543926e9 100644 --- a/backends/occa/kernels/tensor-basis/cpu/tensor-basis-1d.cpp +++ b/backends/occa/kernels/tensor-basis/cpu/tensor-basis-1d.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "../../kernel-defines.hpp" diff --git a/backends/occa/kernels/tensor-basis/cpu/tensor-basis-2d.cpp b/backends/occa/kernels/tensor-basis/cpu/tensor-basis-2d.cpp index 7476416aab..1a237d7258 100644 --- a/backends/occa/kernels/tensor-basis/cpu/tensor-basis-2d.cpp +++ b/backends/occa/kernels/tensor-basis/cpu/tensor-basis-2d.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "../../kernel-defines.hpp" diff --git a/backends/occa/kernels/tensor-basis/cpu/tensor-basis-3d.cpp b/backends/occa/kernels/tensor-basis/cpu/tensor-basis-3d.cpp index 63a38a07aa..1d3a94ebbd 100644 --- a/backends/occa/kernels/tensor-basis/cpu/tensor-basis-3d.cpp +++ b/backends/occa/kernels/tensor-basis/cpu/tensor-basis-3d.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "../../kernel-defines.hpp" diff --git a/backends/occa/kernels/tensor-basis/gpu/tensor-basis-1d.cpp b/backends/occa/kernels/tensor-basis/gpu/tensor-basis-1d.cpp index 0cc5973ba0..25e9d086b7 100644 --- a/backends/occa/kernels/tensor-basis/gpu/tensor-basis-1d.cpp +++ b/backends/occa/kernels/tensor-basis/gpu/tensor-basis-1d.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "../../kernel-defines.hpp" diff --git a/backends/occa/kernels/tensor-basis/gpu/tensor-basis-2d.cpp b/backends/occa/kernels/tensor-basis/gpu/tensor-basis-2d.cpp index 5d175200d3..a987144665 100644 --- a/backends/occa/kernels/tensor-basis/gpu/tensor-basis-2d.cpp +++ b/backends/occa/kernels/tensor-basis/gpu/tensor-basis-2d.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "../../kernel-defines.hpp" diff --git a/backends/occa/kernels/tensor-basis/gpu/tensor-basis-3d.cpp b/backends/occa/kernels/tensor-basis/gpu/tensor-basis-3d.cpp index 8f7c4e8f69..96d70f69c3 100644 --- a/backends/occa/kernels/tensor-basis/gpu/tensor-basis-3d.cpp +++ b/backends/occa/kernels/tensor-basis/gpu/tensor-basis-3d.cpp @@ -1,18 +1,9 @@ -// Copyright (c) 2019, Lawrence Livermore National Security, LLC. -// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. -// All Rights reserved. See files LICENSE and NOTICE for details. +// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. +// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // -// This file is part of CEED, a collection of benchmarks, miniapps, software -// libraries and APIs for efficient high-order finite element and spectral -// element discretizations for exascale applications. For more information and -// source code availability see http://github.com/ceed +// SPDX-License-Identifier: BSD-2-Clause // -// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, -// a collaborative effort of two U.S. Department of Energy organizations (Office -// of Science and the National Nuclear Security Administration) responsible for -// the planning and preparation of a capable exascale ecosystem, including -// software, applications, hardware, advanced system engineering and early -// testbed platforms, in support of the nation's exascale computing imperative. +// This file is part of CEED: http://github.com/ceed #include "../../kernel-defines.hpp" diff --git a/doc/sphinx/source/releasenotes.md b/doc/sphinx/source/releasenotes.md index 9a2c0dcf88..28b84c2b57 100644 --- a/doc/sphinx/source/releasenotes.md +++ b/doc/sphinx/source/releasenotes.md @@ -16,6 +16,9 @@ On this page we provide a summary of the main API changes, new features and exam - Update `/cpu/self/memcheck/*` backends to help verify `CeedQFunctionContext` data sizes provided by user. - Added `CeedInt_FMT` to support potential future use of larger interger sizes. - Added CEED_QFUNCTION_ATTR for setting compiler attributes/pragmas to CEED_QFUNCTION_HELPER and CEED_QFUNCTION +- OCCA backend updated to latest OCCA release; DPC++ and OMP OCCA modes enabled. +Due to a limitation of the OCCA parser, typedefs are required to use pointers to arrays in QFunctions with the OCCA backend. +This issue will be fixed in a future OCCA release. ### Bugfix diff --git a/tests/junit.py b/tests/junit.py index 04faaf5243..83b4ee846d 100755 --- a/tests/junit.py +++ b/tests/junit.py @@ -61,10 +61,14 @@ def contains_any(resource, substrings): def skip_rule(test, resource): return any(( + test.startswith('t4') and contains_any(resource, ['occa']), + test.startswith('t5') and contains_any(resource, ['occa']), + test.startswith('ex') and contains_any(resource, ['occa']), + test.startswith('mfem') and contains_any(resource, ['occa']), + test.startswith('nek') and contains_any(resource, ['occa']), + test.startswith('petsc-') and contains_any(resource, ['occa']), test.startswith('fluids-') and contains_any(resource, ['occa']), test.startswith('solids-') and contains_any(resource, ['occa']), - test.startswith('nek') and contains_any(resource, ['occa']), - test.startswith('t507') and contains_any(resource, ['occa']), test.startswith('t318') and contains_any(resource, ['/gpu/cuda/ref']), test.startswith('t506') and contains_any(resource, ['/gpu/cuda/shared']), ))