Skip to content

Commit

Permalink
Fix bug for p-multigrid with signed restrictions: Refactor to remove …
Browse files Browse the repository at this point in the history
…need for extra CeedElemRestrctionApplyUnsigned method and rely on temporary restriction objects instead
  • Loading branch information
sebastiangrimberg committed Apr 27, 2023
1 parent 53a539d commit 95a7a95
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 187 deletions.
1 change: 0 additions & 1 deletion backends/cuda-ref/ceed-cuda-restriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ int CeedElemRestrictionCreate_Cuda(CeedMemType mem_type, CeedCopyMode copy_mode,

// Register backend functions
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "Apply", CeedElemRestrictionApply_Cuda));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "ApplyUnsigned", CeedElemRestrictionApply_Cuda));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "GetOffsets", CeedElemRestrictionGetOffsets_Cuda));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "Destroy", CeedElemRestrictionDestroy_Cuda));
return CEED_ERROR_SUCCESS;
Expand Down
1 change: 0 additions & 1 deletion backends/hip-ref/ceed-hip-ref-restriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ int CeedElemRestrictionCreate_Hip(CeedMemType mem_type, CeedCopyMode copy_mode,

// Register backend functions
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "Apply", CeedElemRestrictionApply_Hip));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "ApplyUnsigned", CeedElemRestrictionApply_Hip));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "GetOffsets", CeedElemRestrictionGetOffsets_Hip));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "Destroy", CeedElemRestrictionDestroy_Hip));
return CEED_ERROR_SUCCESS;
Expand Down
1 change: 0 additions & 1 deletion backends/magma/ceed-magma-restriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ int CeedElemRestrictionCreate_Magma(CeedMemType mtype, CeedCopyMode cmode, const
CeedInt layout[3] = {1, elemsize * nelem, elemsize};
CeedCallBackend(CeedElemRestrictionSetELayout(r, layout));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "Apply", CeedElemRestrictionApply_Magma));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "ApplyUnsigned", CeedElemRestrictionApply_Magma));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "GetOffsets", CeedElemRestrictionGetOffsets_Magma));
CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", r, "Destroy", CeedElemRestrictionDestroy_Magma));
CeedCallBackend(CeedFree(&restriction_kernel_path));
Expand Down
1 change: 0 additions & 1 deletion backends/occa/ceed-occa-elem-restriction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ int ElemRestriction::ceedCreate(CeedMemType memType, CeedCopyMode copyMode, cons
CeedChkBackend(CeedElemRestrictionSetELayout(r, defaultLayout));

CeedOccaRegisterFunction(r, "Apply", ElemRestriction::ceedApply);
CeedOccaRegisterFunction(r, "ApplyUnsigned", ElemRestriction::ceedApply);
CeedOccaRegisterFunction(r, "ApplyBlock", ElemRestriction::ceedApplyBlock);
CeedOccaRegisterFunction(r, "GetOffsets", ElemRestriction::ceedGetOffsets);
CeedOccaRegisterFunction(r, "Destroy", ElemRestriction::ceedDestroy);
Expand Down
148 changes: 47 additions & 101 deletions backends/ref/ceed-ref-restriction.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backends/ref/ceed-ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ typedef struct {
bool *orients_allocated;
const CeedInt *curl_orients; /* Tridiagonal matrix (row-major) for a general transformation during restriction */
CeedInt *curl_orients_allocated;
int (*Apply)(CeedElemRestriction, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt, bool, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
int (*Apply)(CeedElemRestriction, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
} CeedElemRestriction_Ref;

typedef struct {
Expand Down
1 change: 0 additions & 1 deletion include/ceed-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ struct CeedVector_private {
struct CeedElemRestriction_private {
Ceed ceed;
int (*Apply)(CeedElemRestriction, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
int (*ApplyUnsigned)(CeedElemRestriction, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
int (*ApplyBlock)(CeedElemRestriction, CeedInt, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
int (*GetOffsets)(CeedElemRestriction, CeedMemType, const CeedInt **);
int (*GetOrientations)(CeedElemRestriction, CeedMemType, const bool **);
Expand Down
2 changes: 0 additions & 2 deletions include/ceed/ceed.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ CEED_EXTERN int CeedElemRestrictionCreateBlockedStrided(Ceed ceed, CeedInt num_e
CEED_EXTERN int CeedElemRestrictionReferenceCopy(CeedElemRestriction rstr, CeedElemRestriction *rstr_copy);
CEED_EXTERN int CeedElemRestrictionCreateVector(CeedElemRestriction rstr, CeedVector *lvec, CeedVector *evec);
CEED_EXTERN int CeedElemRestrictionApply(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector ru, CeedRequest *request);
CEED_EXTERN int CeedElemRestrictionApplyUnsigned(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector ru,
CeedRequest *request);
CEED_EXTERN int CeedElemRestrictionApplyBlock(CeedElemRestriction rstr, CeedInt block, CeedTransposeMode t_mode, CeedVector u, CeedVector ru,
CeedRequest *request);
CEED_EXTERN int CeedElemRestrictionGetCeed(CeedElemRestriction rstr, Ceed *ceed);
Expand Down
35 changes: 0 additions & 35 deletions interface/ceed-elemrestriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,41 +933,6 @@ int CeedElemRestrictionApply(CeedElemRestriction rstr, CeedTransposeMode t_mode,
return CEED_ERROR_SUCCESS;
}

/**
@brief Restrict an L-vector to an E-vector or apply its transpose ignoring any
provided orientations
@param[in] rstr CeedElemRestriction
@param[in] t_mode Apply restriction or transpose
@param[in] u Input vector (of size @a l_size when t_mode=@ref CEED_NOTRANSPOSE)
@param[out] ru Output vector (of shape [@a num_elem * @a elem_size] when t_mode=@ref CEED_NOTRANSPOSE).
Ordering of the e-vector is decided by the backend.
@param[in] request Request or @ref CEED_REQUEST_IMMEDIATE
@return An error code: 0 - success, otherwise - failure
@ref User
**/
int CeedElemRestrictionApplyUnsigned(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector ru, CeedRequest *request) {
CeedInt m, n;

CeedCheck(rstr->ApplyUnsigned, rstr->ceed, CEED_ERROR_UNSUPPORTED, "Backend does not support ElemRestrictionApplyUnsigned");

if (t_mode == CEED_NOTRANSPOSE) {
m = rstr->num_blk * rstr->blk_size * rstr->elem_size * rstr->num_comp;
n = rstr->l_size;
} else {
m = rstr->l_size;
n = rstr->num_blk * rstr->blk_size * rstr->elem_size * rstr->num_comp;
}
CeedCheck(n == u->length, rstr->ceed, CEED_ERROR_DIMENSION,
"Input vector size %" CeedInt_FMT " not compatible with element restriction (%" CeedInt_FMT ", %" CeedInt_FMT ")", u->length, m, n);
CeedCheck(m == ru->length, rstr->ceed, CEED_ERROR_DIMENSION,
"Output vector size %" CeedInt_FMT " not compatible with element restriction (%" CeedInt_FMT ", %" CeedInt_FMT ")", ru->length, m, n);
if (rstr->num_elem > 0) CeedCall(rstr->ApplyUnsigned(rstr, t_mode, u, ru, request));
return CEED_ERROR_SUCCESS;
}

/**
@brief Restrict an L-vector to a block of an E-vector or apply its transpose
Expand Down
Loading

0 comments on commit 95a7a95

Please sign in to comment.