Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] OCCA Backend Update #1043

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c4ab772
Removes deprecated calls to `occa::linalg`.
kris-rowe Aug 22, 2022
31a7629
Adds a dummy `ceed.h` header in include in OCCA kernels.
kris-rowe Aug 24, 2022
1a3a1f9
Rewrite arrays of structs in format that OCCA can handle.
kris-rowe Aug 24, 2022
3df7633
Includes the cmath header when compiling C++ code.
kris-rowe Aug 24, 2022
f1b142f
Removes math function headers which were causing OCCA JIT failures.
kris-rowe Aug 25, 2022
1a6fffd
Rewrite arrays of structs in format that OCCA can handle.
kris-rowe Aug 25, 2022
0aacae8
Rewrites fluids example qfunctions to be compatible with OCCA.
kris-rowe Aug 26, 2022
a879016
Rewrites advection problem kernels to work with OCCA.
kris-rowe Aug 30, 2022
177848b
Rewrites blasius problem kernels to work with OCCA.
kris-rowe Aug 30, 2022
4b11b94
Rewrites channel problem kernels to work with OCCA.
kris-rowe Aug 30, 2022
46d6695
Rewrites dirichlet bc kernels to work with OCCA.
kris-rowe Aug 30, 2022
aed20a0
Rewrites newtonian kernels to work with OCCA.
kris-rowe Aug 30, 2022
818ef30
Rewrites setupgeo kernels to be compatible with OCCA.
kris-rowe Aug 30, 2022
b97eee4
Rewrites stabilization kernels to be compatible with OCCA.
kris-rowe Aug 30, 2022
9890d73
Rewrites stg kernels to be compatible with OCCA.
kris-rowe Aug 30, 2022
df482e8
Saves WIP before rebasing onto upstream libCEED.
kris-rowe Oct 25, 2022
f75f425
Rewrites pointer-to-array in t507 to be compatible with OCCA.
kris-rowe Oct 25, 2022
1760b84
Removes filters excluding OCCA from certain tests.
kris-rowe Dec 1, 2022
eca1eaf
Removes previous merge conflicts.
kris-rowe Dec 6, 2022
bc3b4f6
Includes correct math header to be compatible with OCCA.
kris-rowe Dec 6, 2022
2d6dba8
Appends `OCCA_DIR/lib` to LD_LIBRARY_PATH instead of overwriting.
kris-rowe Dec 6, 2022
0c5cb32
Save WIP on OCCA backend to push to GitHub.
kris-rowe Dec 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ endif
# OCCA Backends
OCCA_BACKENDS = /cpu/self/occa
ifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),)
OCCA_MODES := $(shell LD_LIBRARY_PATH=$(OCCA_DIR)/lib $(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 dpcpp,$(OCCA_MODES)),/gpu/dpcpp/occa)
OCCA_BACKENDS += $(if $(filter OpenCL,$(OCCA_MODES)),/gpu/opencl/occa)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,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 |
| `/cpu/dpcpp/occa` | OCCA backend with SYCL/DPC++ kernels | Yes |
| `/gpu/cuda/occa` | OCCA backend with CUDA kernels | Yes |
| `/gpu/hip/occa`~ | OCCA backend with HIP kernels | Yes |

Expand Down
13 changes: 11 additions & 2 deletions backends/occa/ceed-occa-operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ int Operator::ceedCreate(CeedOperator op) {
CeedOccaRegisterFunction(op, "LinearAssembleQFunctionUpdate", Operator::ceedLinearAssembleQFunction);
CeedOccaRegisterFunction(op, "LinearAssembleAddDiagonal", Operator::ceedLinearAssembleAddDiagonal);
CeedOccaRegisterFunction(op, "LinearAssembleAddPointBlockDiagonal", Operator::ceedLinearAssembleAddPointBlockDiagonal);
CeedOccaRegisterFunction(op, "LinearAssembleSingle", Operator::ceedLinearAssembleSingle);
CeedOccaRegisterFunction(op, "CreateFDMElementInverse", Operator::ceedCreateFDMElementInverse);
CeedOccaRegisterFunction(op, "ApplyAdd", Operator::ceedApplyAdd);
CeedOccaRegisterFunction(op, "Destroy", Operator::ceedDestroy);
Expand All @@ -117,18 +118,26 @@ int Operator::ceedCreateComposite(CeedOperator op) {
return CEED_ERROR_SUCCESS;
}

int Operator::ceedLinearAssembleQFunction(CeedOperator op) { return staticCeedError("(OCCA) Backend does not implement LinearAssembleQFunction"); }
int Operator::ceedLinearAssembleQFunction(CeedOperator op) {
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::ceedLinearAssembleAddDiagonal(CeedOperator op) {
return staticCeedError("(OCCA) Backend does not implement LinearAssembleDiagonal");
}

int Operator::ceedLinearAssembleAddPointBlockDiagonal(CeedOperator op) {
return staticCeedError("(OCCA) Backend does not implement LinearAssemblePointBlockDiagonal");
}

int Operator::ceedLinearAssembleSingle(CeedOperator op) {
return staticCeedError("(OCCA) Backend does not implement LinearAssembleSingle");
}

int Operator::ceedCreateFDMElementInverse(CeedOperator op) { return staticCeedError("(OCCA) Backend does not implement CreateFDMElementInverse"); }

int Operator::ceedApplyAdd(CeedOperator op, CeedVector invec, CeedVector outvec, CeedRequest *request) {
Expand Down
1 change: 1 addition & 0 deletions backends/occa/ceed-occa-operator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Operator : public CeedObject {
static int ceedLinearAssembleQFunctionUpdate(CeedOperator op);
static int ceedLinearAssembleAddDiagonal(CeedOperator op);
static int ceedLinearAssembleAddPointBlockDiagonal(CeedOperator op);
static int ceedLinearAssembleSingle(CeedOperator op);
static int ceedCreateFDMElementInverse(CeedOperator op);

static int ceedApplyAdd(CeedOperator op, CeedVector invec, CeedVector outvec, CeedRequest *request);
Expand Down
2 changes: 1 addition & 1 deletion backends/occa/ceed-occa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ CEED_INTERN int CeedRegister_Occa(void) {
CeedCallBackend(CeedRegister("/cpu/openmp/occa", ceed::occa::registerBackend, 250));
// GPU Modes
CeedCallBackend(CeedRegister("/gpu/dpcpp/occa", ceed::occa::registerBackend, 240));
CeedCallBackend(CeedRegister("/gpu/opencl/occa", ceed::occa::registerBackend, 230));
// CeedCallBackend(CeedRegister("/gpu/opencl/occa", ceed::occa::registerBackend, 230));
CeedCallBackend(CeedRegister("/gpu/hip/occa", ceed::occa::registerBackend, 220));
CeedCallBackend(CeedRegister("/gpu/cuda/occa", ceed::occa::registerBackend, 210));
return CEED_ERROR_SUCCESS;
Expand Down
4 changes: 4 additions & 0 deletions backends/occa/include/ceed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef _OCCA_INCLUDE_CEED_H_
Copy link
Member

Choose a reason for hiding this comment

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

If you want to include this during JiT, see the example files like this in `/include/ceed/jit-source/cuda/cuda-jit.h'

Any files that will be used as JiT source should go in include/ceed/jit-source/occa

#define _OCCA_INCLUDE_CEED_H_
// Phony header to include when compiling OKL
#endif
Copy link
Member

@jeremylt jeremylt Oct 25, 2022

Choose a reason for hiding this comment

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

It's really intended that JiT headers don't go here in the backend folder.

23 changes: 23 additions & 0 deletions backends/occa/include/ceed/ceed-f32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// 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

/// @file
/// Public header for definitions related to using FP32 floating point (single
/// precision) for CeedScalar. Include this header in ceed/ceed.h to use
/// float instead of double.
#ifndef _ceed_f32_h
#define _ceed_f32_h

/// Set base scalar type to FP32. (See CeedScalarType enum in ceed/ceed.h
/// for all options.)
#define CEED_SCALAR_TYPE CEED_SCALAR_FP32
typedef float CeedScalar;

/// Machine epsilon
#define CEED_EPSILON 6e-08

#endif
22 changes: 22 additions & 0 deletions backends/occa/include/ceed/ceed-f64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// 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

/// @file
/// Public header for definitions related to using FP64 floating point (double
/// precision) for CeedScalar. This is the default header included in ceed/ceed.h.
#ifndef _ceed_f64_h
#define _ceed_f64_h

/// Set base scalar type to FP64. (See CeedScalarType enum in ceed/ceed.h
/// for all options.)
#define CEED_SCALAR_TYPE CEED_SCALAR_FP64
typedef double CeedScalar;

/// Machine epsilon
#define CEED_EPSILON 1e-16

#endif
Loading