Skip to content

Commit

Permalink
Merge pull request #1647 from CEED/jeremy/fix-call
Browse files Browse the repository at this point in the history
Small Bugfixes
  • Loading branch information
jeremylt committed Aug 22, 2024
2 parents f8a0df5 + df8a6b4 commit bd7a0ce
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 35 deletions.
4 changes: 2 additions & 2 deletions backends/cuda-gen/ceed-cuda-gen-operator-build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,11 @@ extern "C" int CeedOperatorBuildKernel_Cuda_gen(CeedOperator op) {
// Initialize constants, and matrices B and G
code << "\n // Input field constants and basis data\n";
for (CeedInt i = 0; i < num_input_fields; i++) {
CeedCall(CeedOperatorBuildKernelFieldData_Cuda_gen(code, data, i, op_input_fields[i], qf_input_fields[i], Q_1d, true, use_3d_slices));
CeedCallBackend(CeedOperatorBuildKernelFieldData_Cuda_gen(code, data, i, op_input_fields[i], qf_input_fields[i], Q_1d, true, use_3d_slices));
}
code << "\n // Output field constants and basis data\n";
for (CeedInt i = 0; i < num_output_fields; i++) {
CeedCall(CeedOperatorBuildKernelFieldData_Cuda_gen(code, data, i, op_output_fields[i], qf_output_fields[i], Q_1d, false, use_3d_slices));
CeedCallBackend(CeedOperatorBuildKernelFieldData_Cuda_gen(code, data, i, op_output_fields[i], qf_output_fields[i], Q_1d, false, use_3d_slices));
}

// Loop over all elements
Expand Down
2 changes: 1 addition & 1 deletion backends/cuda-gen/ceed-cuda-gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static int CeedInit_Cuda_gen(const char *resource, Ceed ceed) {
CeedCallBackend(CeedSetData(ceed, data));
CeedCallBackend(CeedInit_Cuda(ceed, resource));

CeedCall(CeedInit("/gpu/cuda/shared", &ceed_shared));
CeedCallBackend(CeedInit("/gpu/cuda/shared", &ceed_shared));
CeedCallBackend(CeedSetDelegate(ceed, ceed_shared));

CeedCallBackend(CeedSetOperatorFallbackResource(ceed, fallback_resource));
Expand Down
4 changes: 2 additions & 2 deletions backends/cuda-ref/ceed-cuda-ref-basis.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static int CeedBasisApplyAtPointsCore_Cuda(CeedBasis basis, bool apply_add, cons

// Weight handled separately
if (eval_mode == CEED_EVAL_WEIGHT) {
CeedCall(CeedVectorSetValue(v, 1.0));
CeedCallBackend(CeedVectorSetValue(v, 1.0));
return CEED_ERROR_SUCCESS;
}

Expand All @@ -141,7 +141,7 @@ static int CeedBasisApplyAtPointsCore_Cuda(CeedBasis basis, bool apply_add, cons

interp_bytes = P_1d * Q_1d * sizeof(CeedScalar);
CeedCallBackend(CeedCalloc(P_1d * Q_1d, &chebyshev_interp_1d));
CeedCall(CeedBasisGetChebyshevInterp1D(basis, chebyshev_interp_1d));
CeedCallBackend(CeedBasisGetChebyshevInterp1D(basis, chebyshev_interp_1d));
CeedCallCuda(ceed, cudaMalloc((void **)&data->d_chebyshev_interp_1d, interp_bytes));
CeedCallCuda(ceed, cudaMemcpy(data->d_chebyshev_interp_1d, chebyshev_interp_1d, interp_bytes, cudaMemcpyHostToDevice));
CeedCallBackend(CeedFree(&chebyshev_interp_1d));
Expand Down
8 changes: 4 additions & 4 deletions backends/cuda-ref/ceed-cuda-ref-restriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ static inline int CeedElemRestrictionSetupCompile_Cuda(CeedElemRestriction rstr)
CeedCallBackend(CeedGetKernel_Cuda(ceed, impl->module, "OffsetTranspose", &impl->ApplyUnsignedTranspose));
// Cleanup
CeedCallBackend(CeedFree(&offset_kernel_path));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCall(CeedFree(&file_paths[i]));
CeedCall(CeedFree(&file_paths));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCallBackend(CeedFree(&file_paths[i]));
CeedCallBackend(CeedFree(&file_paths));
} break;
case CEED_RESTRICTION_CURL_ORIENTED: {
const char *offset_kernel_path;
Expand All @@ -137,8 +137,8 @@ static inline int CeedElemRestrictionSetupCompile_Cuda(CeedElemRestriction rstr)
CeedCallBackend(CeedGetKernel_Cuda(ceed, impl->module, "OffsetTranspose", &impl->ApplyUnorientedTranspose));
// Cleanup
CeedCallBackend(CeedFree(&offset_kernel_path));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCall(CeedFree(&file_paths[i]));
CeedCall(CeedFree(&file_paths));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCallBackend(CeedFree(&file_paths[i]));
CeedCallBackend(CeedFree(&file_paths));
} break;
}
CeedCallBackend(CeedFree(&restriction_kernel_path));
Expand Down
4 changes: 2 additions & 2 deletions backends/cuda-ref/ceed-cuda-ref-vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ static int CeedVectorCopyStrided_Cuda(CeedVector vec, CeedSize start, CeedSize s
{
CeedSize length_vec, length_copy;

CeedCall(CeedVectorGetLength(vec, &length_vec));
CeedCall(CeedVectorGetLength(vec_copy, &length_copy));
CeedCallBackend(CeedVectorGetLength(vec, &length_vec));
CeedCallBackend(CeedVectorGetLength(vec_copy, &length_copy));
length = length_vec < length_copy ? length_vec : length_copy;
}
// Set value for synced device/host array
Expand Down
4 changes: 2 additions & 2 deletions backends/cuda-shared/ceed-cuda-shared-basis.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static int CeedBasisApplyAtPointsCore_Cuda_shared(CeedBasis basis, bool apply_ad

// Weight handled separately
if (eval_mode == CEED_EVAL_WEIGHT) {
CeedCall(CeedVectorSetValue(v, 1.0));
CeedCallBackend(CeedVectorSetValue(v, 1.0));
return CEED_ERROR_SUCCESS;
}

Expand All @@ -247,7 +247,7 @@ static int CeedBasisApplyAtPointsCore_Cuda_shared(CeedBasis basis, bool apply_ad

interp_bytes = P_1d * Q_1d * sizeof(CeedScalar);
CeedCallBackend(CeedCalloc(P_1d * Q_1d, &chebyshev_interp_1d));
CeedCall(CeedBasisGetChebyshevInterp1D(basis, chebyshev_interp_1d));
CeedCallBackend(CeedBasisGetChebyshevInterp1D(basis, chebyshev_interp_1d));
CeedCallCuda(ceed, cudaMalloc((void **)&data->d_chebyshev_interp_1d, interp_bytes));
CeedCallCuda(ceed, cudaMemcpy(data->d_chebyshev_interp_1d, chebyshev_interp_1d, interp_bytes, cudaMemcpyHostToDevice));
CeedCallBackend(CeedFree(&chebyshev_interp_1d));
Expand Down
1 change: 1 addition & 0 deletions backends/cuda-shared/ceed-cuda-shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static int CeedInit_Cuda_shared(const char *resource, Ceed ceed) {

CeedCallBackend(CeedGetResourceRoot(ceed, resource, ":", &resource_root));
CeedCheck(!strcmp(resource_root, "/gpu/cuda/shared"), ceed, CEED_ERROR_BACKEND, "Cuda backend cannot use resource: %s", resource);
CeedCallBackend(CeedFree(&resource_root));
CeedCallBackend(CeedSetDeterministic(ceed, true));

CeedCallBackend(CeedCalloc(1, &data));
Expand Down
4 changes: 2 additions & 2 deletions backends/hip-gen/ceed-hip-gen-operator-build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,11 @@ extern "C" int CeedOperatorBuildKernel_Hip_gen(CeedOperator op) {
// Initialize constants, and matrices B and G
code << "\n // Input field constants and basis data\n";
for (CeedInt i = 0; i < num_input_fields; i++) {
CeedCall(CeedOperatorBuildKernelFieldData_Hip_gen(code, data, i, op_input_fields[i], qf_input_fields[i], Q_1d, true, use_3d_slices));
CeedCallBackend(CeedOperatorBuildKernelFieldData_Hip_gen(code, data, i, op_input_fields[i], qf_input_fields[i], Q_1d, true, use_3d_slices));
}
code << "\n // Output field constants and basis data\n";
for (CeedInt i = 0; i < num_output_fields; i++) {
CeedCall(CeedOperatorBuildKernelFieldData_Hip_gen(code, data, i, op_output_fields[i], qf_output_fields[i], Q_1d, false, use_3d_slices));
CeedCallBackend(CeedOperatorBuildKernelFieldData_Hip_gen(code, data, i, op_output_fields[i], qf_output_fields[i], Q_1d, false, use_3d_slices));
}

// Loop over all elements
Expand Down
4 changes: 2 additions & 2 deletions backends/hip-ref/ceed-hip-ref-basis.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int CeedBasisApplyAtPointsCore_Hip(CeedBasis basis, bool apply_add, const

// Weight handled separately
if (eval_mode == CEED_EVAL_WEIGHT) {
CeedCall(CeedVectorSetValue(v, 1.0));
CeedCallBackend(CeedVectorSetValue(v, 1.0));
return CEED_ERROR_SUCCESS;
}

Expand All @@ -139,7 +139,7 @@ static int CeedBasisApplyAtPointsCore_Hip(CeedBasis basis, bool apply_add, const

interp_bytes = P_1d * Q_1d * sizeof(CeedScalar);
CeedCallBackend(CeedCalloc(P_1d * Q_1d, &chebyshev_interp_1d));
CeedCall(CeedBasisGetChebyshevInterp1D(basis, chebyshev_interp_1d));
CeedCallBackend(CeedBasisGetChebyshevInterp1D(basis, chebyshev_interp_1d));
CeedCallHip(ceed, hipMalloc((void **)&data->d_chebyshev_interp_1d, interp_bytes));
CeedCallHip(ceed, hipMemcpy(data->d_chebyshev_interp_1d, chebyshev_interp_1d, interp_bytes, hipMemcpyHostToDevice));
CeedCallBackend(CeedFree(&chebyshev_interp_1d));
Expand Down
8 changes: 4 additions & 4 deletions backends/hip-ref/ceed-hip-ref-restriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ static inline int CeedElemRestrictionSetupCompile_Hip(CeedElemRestriction rstr)
CeedCallBackend(CeedGetKernel_Hip(ceed, impl->module, "OffsetTranspose", &impl->ApplyUnsignedTranspose));
// Cleanup
CeedCallBackend(CeedFree(&offset_kernel_path));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCall(CeedFree(&file_paths[i]));
CeedCall(CeedFree(&file_paths));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCallBackend(CeedFree(&file_paths[i]));
CeedCallBackend(CeedFree(&file_paths));
} break;
case CEED_RESTRICTION_CURL_ORIENTED: {
const char *offset_kernel_path;
Expand All @@ -136,8 +136,8 @@ static inline int CeedElemRestrictionSetupCompile_Hip(CeedElemRestriction rstr)
CeedCallBackend(CeedGetKernel_Hip(ceed, impl->module, "OffsetTranspose", &impl->ApplyUnorientedTranspose));
// Cleanup
CeedCallBackend(CeedFree(&offset_kernel_path));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCall(CeedFree(&file_paths[i]));
CeedCall(CeedFree(&file_paths));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCallBackend(CeedFree(&file_paths[i]));
CeedCallBackend(CeedFree(&file_paths));
} break;
}
CeedCallBackend(CeedFree(&restriction_kernel_path));
Expand Down
4 changes: 2 additions & 2 deletions backends/hip-ref/ceed-hip-ref-vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ static int CeedVectorCopyStrided_Hip(CeedVector vec, CeedSize start, CeedSize st
{
CeedSize length_vec, length_copy;

CeedCall(CeedVectorGetLength(vec, &length_vec));
CeedCall(CeedVectorGetLength(vec_copy, &length_copy));
CeedCallBackend(CeedVectorGetLength(vec, &length_vec));
CeedCallBackend(CeedVectorGetLength(vec_copy, &length_copy));
length = length_vec < length_copy ? length_vec : length_copy;
}
// Set value for synced device/host array
Expand Down
4 changes: 2 additions & 2 deletions backends/hip-shared/ceed-hip-shared-basis.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ static int CeedBasisApplyAtPointsCore_Hip_shared(CeedBasis basis, bool apply_add

// Weight handled separately
if (eval_mode == CEED_EVAL_WEIGHT) {
CeedCall(CeedVectorSetValue(v, 1.0));
CeedCallBackend(CeedVectorSetValue(v, 1.0));
return CEED_ERROR_SUCCESS;
}

Expand All @@ -306,7 +306,7 @@ static int CeedBasisApplyAtPointsCore_Hip_shared(CeedBasis basis, bool apply_add

interp_bytes = P_1d * Q_1d * sizeof(CeedScalar);
CeedCallBackend(CeedCalloc(P_1d * Q_1d, &chebyshev_interp_1d));
CeedCall(CeedBasisGetChebyshevInterp1D(basis, chebyshev_interp_1d));
CeedCallBackend(CeedBasisGetChebyshevInterp1D(basis, chebyshev_interp_1d));
CeedCallHip(ceed, hipMalloc((void **)&data->d_chebyshev_interp_1d, interp_bytes));
CeedCallHip(ceed, hipMemcpy(data->d_chebyshev_interp_1d, chebyshev_interp_1d, interp_bytes, hipMemcpyHostToDevice));
CeedCallBackend(CeedFree(&chebyshev_interp_1d));
Expand Down
8 changes: 4 additions & 4 deletions backends/magma/ceed-magma-basis.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ static int CeedBasisApplyNonTensorCore_Magma(CeedBasis basis, bool apply_add, Ce
}
CeedCallBackend(CeedFree(&basis_kernel_path));
CeedCallBackend(CeedFree(&basis_kernel_source));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCall(CeedFree(&file_paths[i]));
CeedCall(CeedFree(&file_paths));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCallBackend(CeedFree(&file_paths[i]));
CeedCallBackend(CeedFree(&file_paths));
}
}

Expand Down Expand Up @@ -617,8 +617,8 @@ int CeedBasisCreateTensorH1_Magma(CeedInt dim, CeedInt P_1d, CeedInt Q_1d, const
CeedCallBackend(CeedFree(&grad_kernel_path));
CeedCallBackend(CeedFree(&weight_kernel_path));
CeedCallBackend(CeedFree(&basis_kernel_source));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCall(CeedFree(&file_paths[i]));
CeedCall(CeedFree(&file_paths));
for (CeedInt i = 0; i < num_file_paths; i++) CeedCallBackend(CeedFree(&file_paths[i]));
CeedCallBackend(CeedFree(&file_paths));

CeedCallBackend(CeedBasisSetData(basis, impl));

Expand Down
2 changes: 1 addition & 1 deletion backends/sycl/ceed-sycl-compile.sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static int CeedLoadModule_Sycl(Ceed ceed, const sycl::context &sycl_context, con

zeModuleBuildLogGetString(lz_log, &log_size, nullptr);

CeedCall(CeedCalloc(log_size, &log_message));
CeedCallBackend(CeedCalloc(log_size, &log_message));
zeModuleBuildLogGetString(lz_log, &log_size, log_message);

return CeedError(ceed, CEED_ERROR_BACKEND, "Failed to compile Level Zero module:\n%s", log_message);
Expand Down
4 changes: 3 additions & 1 deletion interface/ceed.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ int CeedIsDebug(Ceed ceed, bool *is_debug) {
}

/**
@brief Get the root of the requested resource
@brief Get the root of the requested resource.
Note: Caller is responsible for calling @ref CeedFree() on the `resource_root`.
@param[in] ceed `Ceed` context to get resource name of
@param[in] resource Full user specified resource
Expand Down
4 changes: 2 additions & 2 deletions tests/t593-operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ int main(int argc, char **argv) {

// Setup geometric scaling
CeedQFunctionCreateInterior(ceed, 1, setup, setup_loc, &qf_setup);
CeedQFunctionAddInput(qf_setup, "x", dim * dim, CEED_EVAL_GRAD);
CeedQFunctionAddInput(qf_setup, "weight", 1, CEED_EVAL_WEIGHT);
CeedQFunctionAddInput(qf_setup, "x", dim * dim, CEED_EVAL_GRAD);
CeedQFunctionAddOutput(qf_setup, "rho", 1, CEED_EVAL_NONE);

CeedOperatorCreateAtPoints(ceed, qf_setup, CEED_QFUNCTION_NONE, CEED_QFUNCTION_NONE, &op_setup);
CeedOperatorSetField(op_setup, "x", elem_restriction_x, basis_x, CEED_VECTOR_ACTIVE);
CeedOperatorSetField(op_setup, "weight", CEED_ELEMRESTRICTION_NONE, basis_x, CEED_VECTOR_NONE);
CeedOperatorSetField(op_setup, "x", elem_restriction_x, basis_x, CEED_VECTOR_ACTIVE);
CeedOperatorSetField(op_setup, "rho", elem_restriction_q_data, CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
CeedOperatorAtPointsSetPoints(op_setup, elem_restriction_x_points, x_points);

Expand Down
4 changes: 2 additions & 2 deletions tests/t594-operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ int main(int argc, char **argv) {

// Setup geometric scaling
CeedQFunctionCreateInterior(ceed, 1, setup, setup_loc, &qf_setup);
CeedQFunctionAddInput(qf_setup, "x", dim * dim, CEED_EVAL_GRAD);
CeedQFunctionAddInput(qf_setup, "weight", 1, CEED_EVAL_WEIGHT);
CeedQFunctionAddInput(qf_setup, "x", dim * dim, CEED_EVAL_GRAD);
CeedQFunctionAddOutput(qf_setup, "rho", 1, CEED_EVAL_NONE);

CeedOperatorCreateAtPoints(ceed, qf_setup, CEED_QFUNCTION_NONE, CEED_QFUNCTION_NONE, &op_setup);
CeedOperatorSetField(op_setup, "x", elem_restriction_x, basis_x, CEED_VECTOR_ACTIVE);
CeedOperatorSetField(op_setup, "weight", CEED_ELEMRESTRICTION_NONE, basis_x, CEED_VECTOR_NONE);
CeedOperatorSetField(op_setup, "x", elem_restriction_x, basis_x, CEED_VECTOR_ACTIVE);
CeedOperatorSetField(op_setup, "rho", elem_restriction_q_data, CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
CeedOperatorAtPointsSetPoints(op_setup, elem_restriction_x_points, x_points);

Expand Down

0 comments on commit bd7a0ce

Please sign in to comment.