Skip to content

Commit

Permalink
Merge pull request #1202 from CEED/jeremy/const-fix
Browse files Browse the repository at this point in the history
Clean up backend headers for const and argument names
  • Loading branch information
jeremylt authored Apr 25, 2023
2 parents 1acfd91 + 472941f commit 30d6126
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 50 deletions.
2 changes: 1 addition & 1 deletion backends/blocked/ceed-blocked.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//------------------------------------------------------------------------------
// Backend Init
//------------------------------------------------------------------------------
CEED_INTERN int CeedInit_Blocked(const char *resource, Ceed ceed) {
static int CeedInit_Blocked(const char *resource, Ceed ceed) {
CeedCheck(!strcmp(resource, "/cpu/self") || !strcmp(resource, "/cpu/self/ref/blocked"), ceed, CEED_ERROR_BACKEND,
"Blocked backend cannot use resource: %s", resource);
CeedCallBackend(CeedSetDeterministic(ceed, true));
Expand Down
2 changes: 1 addition & 1 deletion backends/cuda-ref/ceed-cuda-ref-basis.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ int CeedBasisCreateTensorH1_Cuda(CeedInt dim, CeedInt P_1d, CeedInt Q_1d, const
// Create non-tensor
//------------------------------------------------------------------------------
int CeedBasisCreateH1_Cuda(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp, const CeedScalar *grad,
const CeedScalar *qref, const CeedScalar *q_weight, CeedBasis basis) {
const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis) {
Ceed ceed;
CeedCallBackend(CeedBasisGetCeed(basis, &ceed));
CeedBasisNonTensor_Cuda *data;
Expand Down
12 changes: 2 additions & 10 deletions backends/cuda-ref/ceed-cuda-ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,11 @@ CEED_INTERN int CeedVectorCreate_Cuda(CeedSize n, CeedVector vec);

CEED_INTERN int CeedElemRestrictionCreate_Cuda(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *indices, CeedElemRestriction r);

CEED_INTERN int CeedElemRestrictionCreateBlocked_Cuda(const CeedMemType mem_type, const CeedCopyMode copy_mode, const CeedInt *indices,
const CeedElemRestriction res);

CEED_INTERN int CeedBasisApplyElems_Cuda(CeedBasis basis, const CeedInt num_elem, CeedTransposeMode t_mode, CeedEvalMode eval_mode,
const CeedVector u, CeedVector v);

CEED_INTERN int CeedQFunctionApplyElems_Cuda(CeedQFunction qf, const CeedInt Q, const CeedVector *const u, const CeedVector *v);

CEED_INTERN int CeedBasisCreateTensorH1_Cuda(CeedInt dim, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d,
const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis basis);

CEED_INTERN int CeedBasisCreateH1_Cuda(CeedElemTopology, CeedInt, CeedInt, CeedInt, const CeedScalar *, const CeedScalar *, const CeedScalar *,
const CeedScalar *, CeedBasis);
CEED_INTERN int CeedBasisCreateH1_Cuda(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);

CEED_INTERN int CeedQFunctionCreate_Cuda(CeedQFunction qf);

Expand Down
8 changes: 4 additions & 4 deletions backends/cuda-ref/ceed-cuda-restriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ static int CeedElemRestrictionApply_Cuda(CeedElemRestriction r, CeedTransposeMod
//------------------------------------------------------------------------------
// Get offsets
//------------------------------------------------------------------------------
static int CeedElemRestrictionGetOffsets_Cuda(CeedElemRestriction rstr, CeedMemType m_type, const CeedInt **offsets) {
static int CeedElemRestrictionGetOffsets_Cuda(CeedElemRestriction rstr, CeedMemType mem_type, const CeedInt **offsets) {
CeedElemRestriction_Cuda *impl;
CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl));

switch (m_type) {
switch (mem_type) {
case CEED_MEM_HOST:
*offsets = impl->h_ind;
break;
Expand Down Expand Up @@ -209,7 +209,7 @@ static int CeedElemRestrictionOffset_Cuda(const CeedElemRestriction r, const Cee
//------------------------------------------------------------------------------
// Create restriction
//------------------------------------------------------------------------------
int CeedElemRestrictionCreate_Cuda(CeedMemType m_type, CeedCopyMode copy_mode, const CeedInt *indices, CeedElemRestriction r) {
int CeedElemRestrictionCreate_Cuda(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *indices, CeedElemRestriction r) {
Ceed ceed;
CeedCallBackend(CeedElemRestrictionGetCeed(r, &ceed));
CeedElemRestriction_Cuda *impl;
Expand Down Expand Up @@ -247,7 +247,7 @@ int CeedElemRestrictionCreate_Cuda(CeedMemType m_type, CeedCopyMode copy_mode, c
CeedCallBackend(CeedElemRestrictionSetELayout(r, layout));

// Set up device indices/offset arrays
switch (m_type) {
switch (mem_type) {
case CEED_MEM_HOST: {
switch (copy_mode) {
case CEED_OWN_POINTER:
Expand Down
9 changes: 4 additions & 5 deletions backends/cuda/ceed-cuda-compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ CEED_INTERN int CeedCompileCuda(Ceed ceed, const char *source, CUmodule *module,

CEED_INTERN int CeedGetKernelCuda(Ceed ceed, CUmodule module, const char *name, CUfunction *kernel);

CEED_INTERN int CeedRunKernelCuda(Ceed ceed, CUfunction kernel, const int grid_size, const int block_size, void **args);
CEED_INTERN int CeedRunKernelCuda(Ceed ceed, CUfunction kernel, int grid_size, int block_size, void **args);

CEED_INTERN int CeedRunKernelAutoblockCuda(Ceed ceed, CUfunction kernel, size_t points, void **args);

CEED_INTERN int CeedRunKernelDimCuda(Ceed ceed, CUfunction kernel, const int grid_size, const int block_size_x, const int block_size_y,
const int block_size_z, void **args);
CEED_INTERN int CeedRunKernelDimCuda(Ceed ceed, CUfunction kernel, int grid_size, int block_size_x, int block_size_y, int block_size_z, void **args);

CEED_INTERN int CeedRunKernelDimSharedCuda(Ceed ceed, CUfunction kernel, const int grid_size, const int block_size_x, const int block_size_y,
const int block_size_z, const int shared_mem_size, void **args);
CEED_INTERN int CeedRunKernelDimSharedCuda(Ceed ceed, CUfunction kernel, int grid_size, int block_size_x, int block_size_y, int block_size_z,
int shared_mem_size, void **args);

#endif // _ceed_cuda_compile_h
2 changes: 1 addition & 1 deletion backends/hip-gen/ceed-hip-gen-operator-build.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef _ceed_hip_gen_operator_build_h
#define _ceed_hip_gen_operator_build_h

CEED_INTERN int BlockGridCalculate_Hip_gen(const CeedInt dim, const CeedInt num_elem, const CeedInt P_1d, const CeedInt Q_1d, CeedInt *block_sizes);
CEED_INTERN int BlockGridCalculate_Hip_gen(CeedInt dim, CeedInt num_elem, CeedInt P_1d, CeedInt Q_1d, CeedInt *block_sizes);
CEED_INTERN int CeedHipGenOperatorBuild(CeedOperator op);

#endif // _ceed_hip_gen_operator_build_h
2 changes: 1 addition & 1 deletion backends/hip-ref/ceed-hip-ref-basis.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ int CeedBasisCreateTensorH1_Hip(CeedInt dim, CeedInt P_1d, CeedInt Q_1d, const C
// Create non-tensor
//------------------------------------------------------------------------------
int CeedBasisCreateH1_Hip(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp, const CeedScalar *grad,
const CeedScalar *qref, const CeedScalar *q_weight, CeedBasis basis) {
const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis) {
Ceed ceed;
CeedCallBackend(CeedBasisGetCeed(basis, &ceed));
CeedBasisNonTensor_Hip *data;
Expand Down
12 changes: 6 additions & 6 deletions backends/hip-ref/ceed-hip-ref-restriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ static int CeedElemRestrictionApply_Hip(CeedElemRestriction r, CeedTransposeMode
//------------------------------------------------------------------------------
// Get offsets
//------------------------------------------------------------------------------
static int CeedElemRestrictionGetOffsets_Hip(CeedElemRestriction rstr, CeedMemType mtype, const CeedInt **offsets) {
static int CeedElemRestrictionGetOffsets_Hip(CeedElemRestriction rstr, CeedMemType mem_type, const CeedInt **offsets) {
CeedElemRestriction_Hip *impl;
CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl));

switch (mtype) {
switch (mem_type) {
case CEED_MEM_HOST:
*offsets = impl->h_ind;
break;
Expand Down Expand Up @@ -207,7 +207,7 @@ static int CeedElemRestrictionOffset_Hip(const CeedElemRestriction r, const Ceed
//------------------------------------------------------------------------------
// Create restriction
//------------------------------------------------------------------------------
int CeedElemRestrictionCreate_Hip(CeedMemType mtype, CeedCopyMode cmode, const CeedInt *indices, CeedElemRestriction r) {
int CeedElemRestrictionCreate_Hip(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *indices, CeedElemRestriction r) {
Ceed ceed;
CeedCallBackend(CeedElemRestrictionGetCeed(r, &ceed));
CeedElemRestriction_Hip *impl;
Expand Down Expand Up @@ -245,9 +245,9 @@ int CeedElemRestrictionCreate_Hip(CeedMemType mtype, CeedCopyMode cmode, const C
CeedCallBackend(CeedElemRestrictionSetELayout(r, layout));

// Set up device indices/offset arrays
switch (mtype) {
switch (mem_type) {
case CEED_MEM_HOST: {
switch (cmode) {
switch (copy_mode) {
case CEED_OWN_POINTER:
impl->h_ind_allocated = (CeedInt *)indices;
impl->h_ind = (CeedInt *)indices;
Expand All @@ -272,7 +272,7 @@ int CeedElemRestrictionCreate_Hip(CeedMemType mtype, CeedCopyMode cmode, const C
break;
}
case CEED_MEM_DEVICE: {
switch (cmode) {
switch (copy_mode) {
case CEED_COPY_VALUES:
if (indices != NULL) {
CeedCallHip(ceed, hipMalloc((void **)&impl->d_ind, size * sizeof(CeedInt)));
Expand Down
14 changes: 3 additions & 11 deletions backends/hip-ref/ceed-hip-ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,13 @@ CEED_INTERN int CeedHipGetHipblasHandle(Ceed ceed, hipblasHandle_t *handle);

CEED_INTERN int CeedVectorCreate_Hip(CeedSize n, CeedVector vec);

CEED_INTERN int CeedElemRestrictionCreate_Hip(CeedMemType mtype, CeedCopyMode cmode, const CeedInt *indices, CeedElemRestriction r);

CEED_INTERN int CeedElemRestrictionCreateBlocked_Hip(const CeedMemType mtype, const CeedCopyMode cmode, const CeedInt *indices,
const CeedElemRestriction res);

CEED_INTERN int CeedBasisApplyElems_Hip(CeedBasis basis, const CeedInt nelem, CeedTransposeMode tmode, CeedEvalMode emode, const CeedVector u,
CeedVector v);

CEED_INTERN int CeedQFunctionApplyElems_Hip(CeedQFunction qf, const CeedInt Q, const CeedVector *const u, const CeedVector *v);
CEED_INTERN int CeedElemRestrictionCreate_Hip(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *indices, CeedElemRestriction r);

CEED_INTERN int CeedBasisCreateTensorH1_Hip(CeedInt dim, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d,
const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis basis);

CEED_INTERN int CeedBasisCreateH1_Hip(CeedElemTopology, CeedInt, CeedInt, CeedInt, const CeedScalar *, const CeedScalar *, const CeedScalar *,
const CeedScalar *, CeedBasis);
CEED_INTERN int CeedBasisCreateH1_Hip(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);

CEED_INTERN int CeedQFunctionCreate_Hip(CeedQFunction qf);

Expand Down
10 changes: 5 additions & 5 deletions backends/hip/ceed-hip-compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ CEED_INTERN int CeedCompileHip(Ceed ceed, const char *source, hipModule_t *modul

CEED_INTERN int CeedGetKernelHip(Ceed ceed, hipModule_t module, const char *name, hipFunction_t *kernel);

CEED_INTERN int CeedRunKernelHip(Ceed ceed, hipFunction_t kernel, const int grid_size, const int block_size, void **args);
CEED_INTERN int CeedRunKernelHip(Ceed ceed, hipFunction_t kernel, int grid_size, int block_size, void **args);

CEED_INTERN int CeedRunKernelDimHip(Ceed ceed, hipFunction_t kernel, const int grid_size, const int block_size_x, const int block_size_y,
const int block_size_z, void **args);
CEED_INTERN int CeedRunKernelDimHip(Ceed ceed, hipFunction_t kernel, int grid_size, int block_size_x, int block_size_y, int block_size_z,
void **args);

CEED_INTERN int CeedRunKernelDimSharedHip(Ceed ceed, hipFunction_t kernel, const int grid_size, const int block_size_x, const int block_size_y,
const int block_size_z, const int shared_mem_size, void **args);
CEED_INTERN int CeedRunKernelDimSharedHip(Ceed ceed, hipFunction_t kernel, int grid_size, int block_size_x, int block_size_y, int block_size_z,
int shared_mem_size, void **args);

#endif // _ceed_hip_compile_h
3 changes: 0 additions & 3 deletions backends/magma/ceed-magma.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ CEED_INTERN int CeedBasisCreateH1_Magma(CeedElemTopology topo, CeedInt dim, Ceed

CEED_INTERN int CeedElemRestrictionCreate_Magma(CeedMemType mtype, CeedCopyMode cmode, const CeedInt *offsets, CeedElemRestriction r);

CEED_INTERN int CeedElemRestrictionCreateBlocked_Magma(const CeedMemType mtype, const CeedCopyMode cmode, const CeedInt *offsets,
const CeedElemRestriction res);

// comment the line below to use the default magma_is_devptr function
#define magma_is_devptr magma_isdevptr

Expand Down
3 changes: 1 addition & 2 deletions backends/ref/ceed-ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ typedef struct {
// Orientation, if it exists, is true when the face must be flipped (multiplies by -1.).
const bool *orient;
bool *orient_allocated;
int (*Apply)(CeedElemRestriction, const CeedInt, const CeedInt, const CeedInt, CeedInt, CeedInt, CeedTransposeMode, CeedVector, CeedVector,
CeedRequest *);
int (*Apply)(CeedElemRestriction, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
} CeedElemRestriction_Ref;

typedef struct {
Expand Down

0 comments on commit 30d6126

Please sign in to comment.