Skip to content

Commit

Permalink
Merge pull request #1463 from CEED/jeremy/memcheck-strides
Browse files Browse the repository at this point in the history
CEED_STRIDES_BACKEND related updates
  • Loading branch information
jeremylt authored Feb 10, 2024
2 parents 2247a93 + 62c1cb2 commit 72e72e0
Show file tree
Hide file tree
Showing 34 changed files with 989 additions and 66 deletions.
2 changes: 1 addition & 1 deletion backends/blocked/ceed-blocked-operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static int CeedOperatorSetupFields_Blocked(CeedQFunction qf, CeedOperator op, bo
case CEED_RESTRICTION_STRIDED: {
CeedInt strides[3];

CeedCallBackend(CeedElemRestrictionGetStrides(rstr, &strides));
CeedCallBackend(CeedElemRestrictionGetStrides(rstr, strides));
CeedCallBackend(CeedElemRestrictionCreateBlockedStrided(ceed_rstr, num_elem, elem_size, block_size, num_comp, l_size, strides,
&block_rstr[i + start_e]));
} break;
Expand Down
6 changes: 3 additions & 3 deletions backends/cuda-gen/ceed-cuda-gen-operator-build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ extern "C" int CeedOperatorBuildKernel_Cuda_gen(CeedOperator op) {
CeedInt strides[3] = {1, elem_size * num_elem, elem_size};

if (!has_backend_strides) {
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, &strides));
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, strides));
}
code << " // Strides: {" << strides[0] << ", " << strides[1] << ", " << strides[2] << "}\n";
code << " readDofsStrided" << dim << "d<num_comp_in_" << i << ",P_in_" << i << "," << strides[0] << "," << strides[1] << "," << strides[2]
Expand Down Expand Up @@ -503,7 +503,7 @@ extern "C" int CeedOperatorBuildKernel_Cuda_gen(CeedOperator op) {
CeedInt strides[3] = {1, elem_size * num_elem, elem_size};

if (!has_backend_strides) {
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, &strides));
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, strides));
}
code << " // Strides: {" << strides[0] << ", " << strides[1] << ", " << strides[2] << "}\n";
code << " readSliceQuadsStrided"
Expand Down Expand Up @@ -697,7 +697,7 @@ extern "C" int CeedOperatorBuildKernel_Cuda_gen(CeedOperator op) {
CeedInt strides[3] = {1, elem_size * num_elem, elem_size};

if (!has_backend_strides) {
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, &strides));
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, strides));
}
code << " // Strides: {" << strides[0] << ", " << strides[1] << ", " << strides[2] << "}\n";
code << " writeDofsStrided" << dim << "d<num_comp_out_" << i << ",P_out_" << i << "," << strides[0] << "," << strides[1] << "," << strides[2]
Expand Down
22 changes: 17 additions & 5 deletions backends/cuda-ref/ceed-cuda-ref-restriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static inline int CeedElemRestrictionSetupCompile_Cuda(CeedElemRestriction rstr)

CeedCallBackend(CeedElemRestrictionHasBackendStrides(rstr, &has_backend_strides));
if (!has_backend_strides) {
CeedCallBackend(CeedElemRestrictionGetStrides(rstr, &strides));
CeedCallBackend(CeedElemRestrictionGetStrides(rstr, strides));
}

CeedCallBackend(CeedGetJitAbsolutePath(ceed, "ceed/jit-source/cuda/cuda-ref-restriction-strided.h", &restriction_kernel_path));
Expand Down Expand Up @@ -494,8 +494,8 @@ int CeedElemRestrictionCreate_Cuda(CeedMemType mem_type, CeedCopyMode copy_mode,
CeedCallBackend(CeedIsDeterministic(ceed_parent, &is_deterministic));
CeedCallBackend(CeedElemRestrictionGetNumElements(rstr, &num_elem));
CeedCallBackend(CeedElemRestrictionGetElementSize(rstr, &elem_size));
const CeedInt size = num_elem * elem_size;
CeedInt layout[3] = {1, size, elem_size};
CeedCallBackend(CeedElemRestrictionGetType(rstr, &rstr_type));
const CeedInt size = num_elem * elem_size;

CeedCallBackend(CeedCalloc(1, &impl));
impl->num_nodes = size;
Expand All @@ -514,10 +514,22 @@ int CeedElemRestrictionCreate_Cuda(CeedMemType mem_type, CeedCopyMode copy_mode,
impl->d_curl_orients = NULL;
impl->d_curl_orients_allocated = NULL;
CeedCallBackend(CeedElemRestrictionSetData(rstr, impl));
CeedCallBackend(CeedElemRestrictionSetELayout(rstr, layout));

// Set layouts
{
bool has_backend_strides;
CeedInt layout[3] = {1, size, elem_size};

CeedCallBackend(CeedElemRestrictionSetELayout(rstr, layout));
if (rstr_type == CEED_RESTRICTION_STRIDED) {
CeedCallBackend(CeedElemRestrictionHasBackendStrides(rstr, &has_backend_strides));
if (has_backend_strides) {
CeedCallBackend(CeedElemRestrictionSetLLayout(rstr, layout));
}
}
}

// Set up device offset/orientation arrays
CeedCallBackend(CeedElemRestrictionGetType(rstr, &rstr_type));
if (rstr_type != CEED_RESTRICTION_STRIDED) {
switch (mem_type) {
case CEED_MEM_HOST: {
Expand Down
6 changes: 3 additions & 3 deletions backends/hip-gen/ceed-hip-gen-operator-build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ extern "C" int CeedOperatorBuildKernel_Hip_gen(CeedOperator op) {
CeedInt strides[3] = {1, elem_size * num_elem, elem_size};

if (!has_backend_strides) {
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, &strides));
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, strides));
}
code << " // Strides: {" << strides[0] << ", " << strides[1] << ", " << strides[2] << "}\n";
code << " readDofsStrided" << dim << "d<num_comp_in_" << i << ",P_in_" << i << "," << strides[0] << "," << strides[1] << "," << strides[2]
Expand Down Expand Up @@ -512,7 +512,7 @@ extern "C" int CeedOperatorBuildKernel_Hip_gen(CeedOperator op) {
CeedInt strides[3] = {1, elem_size * num_elem, elem_size};

if (!has_backend_strides) {
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, &strides));
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, strides));
}
code << " // Strides: {" << strides[0] << ", " << strides[1] << ", " << strides[2] << "}\n";
code << " readSliceQuadsStrided"
Expand Down Expand Up @@ -707,7 +707,7 @@ extern "C" int CeedOperatorBuildKernel_Hip_gen(CeedOperator op) {
CeedInt strides[3] = {1, elem_size * num_elem, elem_size};

if (!has_backend_strides) {
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, &strides));
CeedCallBackend(CeedElemRestrictionGetStrides(elem_rstr, strides));
}
code << " // Strides: {" << strides[0] << ", " << strides[1] << ", " << strides[2] << "}\n";
code << " writeDofsStrided" << dim << "d<num_comp_out_" << i << ",P_out_" << i << "," << strides[0] << "," << strides[1] << "," << strides[2]
Expand Down
22 changes: 17 additions & 5 deletions backends/hip-ref/ceed-hip-ref-restriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static inline int CeedElemRestrictionSetupCompile_Hip(CeedElemRestriction rstr)

CeedCallBackend(CeedElemRestrictionHasBackendStrides(rstr, &has_backend_strides));
if (!has_backend_strides) {
CeedCallBackend(CeedElemRestrictionGetStrides(rstr, &strides));
CeedCallBackend(CeedElemRestrictionGetStrides(rstr, strides));
}

CeedCallBackend(CeedGetJitAbsolutePath(ceed, "ceed/jit-source/hip/hip-ref-restriction-strided.h", &restriction_kernel_path));
Expand Down Expand Up @@ -493,8 +493,8 @@ int CeedElemRestrictionCreate_Hip(CeedMemType mem_type, CeedCopyMode copy_mode,
CeedCallBackend(CeedIsDeterministic(ceed_parent, &is_deterministic));
CeedCallBackend(CeedElemRestrictionGetNumElements(rstr, &num_elem));
CeedCallBackend(CeedElemRestrictionGetElementSize(rstr, &elem_size));
const CeedInt size = num_elem * elem_size;
CeedInt layout[3] = {1, size, elem_size};
CeedCallBackend(CeedElemRestrictionGetType(rstr, &rstr_type));
const CeedInt size = num_elem * elem_size;

CeedCallBackend(CeedCalloc(1, &impl));
impl->num_nodes = size;
Expand All @@ -513,10 +513,22 @@ int CeedElemRestrictionCreate_Hip(CeedMemType mem_type, CeedCopyMode copy_mode,
impl->d_curl_orients = NULL;
impl->d_curl_orients_allocated = NULL;
CeedCallBackend(CeedElemRestrictionSetData(rstr, impl));
CeedCallBackend(CeedElemRestrictionSetELayout(rstr, layout));

// Set layouts
{
bool has_backend_strides;
CeedInt layout[3] = {1, size, elem_size};

CeedCallBackend(CeedElemRestrictionSetELayout(rstr, layout));
if (rstr_type == CEED_RESTRICTION_STRIDED) {
CeedCallBackend(CeedElemRestrictionHasBackendStrides(rstr, &has_backend_strides));
if (has_backend_strides) {
CeedCallBackend(CeedElemRestrictionSetLLayout(rstr, layout));
}
}
}

// Set up device offset/orientation arrays
CeedCallBackend(CeedElemRestrictionGetType(rstr, &rstr_type));
if (rstr_type != CEED_RESTRICTION_STRIDED) {
switch (mem_type) {
case CEED_MEM_HOST: {
Expand Down
3 changes: 3 additions & 0 deletions backends/memcheck/ceed-memcheck-blocked.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ static int CeedInit_Memcheck(const char *resource, Ceed ceed) {
CeedCallBackend(CeedSetDelegate(ceed, ceed_ref));

CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "VectorCreate", CeedVectorCreate_Memcheck));
CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "ElemRestrictionCreate", CeedElemRestrictionCreate_Memcheck));
CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "ElemRestrictionCreateBlocked", CeedElemRestrictionCreate_Memcheck));
CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "ElemRestrictionCreateAtPoints", CeedElemRestrictionCreate_Memcheck));
CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Memcheck));
CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionContextCreate", CeedQFunctionContextCreate_Memcheck));
return CEED_ERROR_SUCCESS;
Expand Down
Loading

0 comments on commit 72e72e0

Please sign in to comment.