Reduction test pipeline added to mpitest, Error struct changed: new label field
- CHANGED: Error struct has a new label field for labeling an error - The label is what is printed to screen - vtxbuf name lookup moved out of printErrorToScreen/print_error_to_screen - NEW: acScalReductionTestCase and acVecReductionTestCase - Define new test cases by adding them to a list in samples/mpitest/main.cc:main - Minor style change in verification.c to make all Verification functions similar and fit one screen
This commit is contained in:
@@ -29,9 +29,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define ERROR_LABEL_LENGTH 30
|
||||
|
||||
typedef struct {
|
||||
char label[ERROR_LABEL_LENGTH];
|
||||
VertexBufferHandle handle;
|
||||
AcReal model;
|
||||
AcReal candidate;
|
||||
@@ -42,6 +45,22 @@ typedef struct {
|
||||
AcReal minimum_magnitude;
|
||||
} Error;
|
||||
|
||||
typedef struct {
|
||||
char label[ERROR_LABEL_LENGTH];
|
||||
VertexBufferHandle vtxbuf;
|
||||
ReductionType rtype;
|
||||
AcReal candidate;
|
||||
} AcScalReductionTestCase;
|
||||
|
||||
typedef struct {
|
||||
char label[ERROR_LABEL_LENGTH];
|
||||
VertexBufferHandle a;
|
||||
VertexBufferHandle b;
|
||||
VertexBufferHandle c;
|
||||
ReductionType rtype;
|
||||
AcReal candidate;
|
||||
} AcVecReductionTestCase;
|
||||
|
||||
/** TODO comment */
|
||||
Error acGetError(AcReal model, AcReal candidate);
|
||||
|
||||
@@ -76,17 +95,20 @@ AcResult acMeshClear(AcMesh* mesh);
|
||||
AcResult acModelIntegrateStep(AcMesh mesh, const AcReal dt);
|
||||
|
||||
/** TODO */
|
||||
AcReal
|
||||
acModelReduceScal(const AcMesh mesh, const ReductionType rtype, const VertexBufferHandle a);
|
||||
AcReal acModelReduceScal(const AcMesh mesh, const ReductionType rtype, const VertexBufferHandle a);
|
||||
|
||||
/** TODO */
|
||||
AcReal
|
||||
acModelReduceVec(const AcMesh mesh, const ReductionType rtype, const VertexBufferHandle a,
|
||||
const VertexBufferHandle b, const VertexBufferHandle c);
|
||||
AcReal acModelReduceVec(const AcMesh mesh, const ReductionType rtype, const VertexBufferHandle a, const VertexBufferHandle b, const VertexBufferHandle c);
|
||||
|
||||
/** */
|
||||
AcResult acVerifyMesh(const AcMesh model, const AcMesh candidate);
|
||||
|
||||
/** */
|
||||
AcResult acVerifyScalReductions(const AcMesh model, const AcScalReductionTestCase* testCases, const size_t numCases);
|
||||
|
||||
/** */
|
||||
AcResult acVerifyVecReductions(const AcMesh model, const AcVecReductionTestCase* testCases, const size_t numCases);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#if AC_MPI_ENABLED
|
||||
|
||||
#include <mpi.h>
|
||||
#include <vector>
|
||||
|
||||
int
|
||||
main(void)
|
||||
@@ -53,12 +54,32 @@ main(void)
|
||||
acGridIntegrate(STREAM_DEFAULT, FLT_EPSILON);
|
||||
acGridPeriodicBoundconds(STREAM_DEFAULT);
|
||||
|
||||
// Do reductions
|
||||
AcReal cand_reduce_res = 0;
|
||||
VertexBufferHandle vtxbuf = VTXBUF_UUX;
|
||||
ReductionType rtype = RTYPE_MAX;
|
||||
acGridReduceScal(STREAM_DEFAULT, rtype, vtxbuf, &cand_reduce_res); // TODO
|
||||
// clang-format off
|
||||
// Define scalar reduction tests here
|
||||
std::vector<AcScalReductionTestCase> scalarReductionTests{
|
||||
AcScalReductionTestCase{"Scalar MAX", VTXBUF_UUX, RTYPE_MAX, 0},
|
||||
AcScalReductionTestCase{"Scalar MIN", VTXBUF_UUX, RTYPE_MIN, 0},
|
||||
AcScalReductionTestCase{"Scalar RMS", VTXBUF_UUX, RTYPE_RMS, 0},
|
||||
AcScalReductionTestCase{"Scalar RMS_EXP", VTXBUF_UUX, RTYPE_RMS_EXP, 0},
|
||||
AcScalReductionTestCase{"Scalar SUM", VTXBUF_UUX, RTYPE_SUM, 0}
|
||||
};
|
||||
// Define vector reduction tests here
|
||||
std::vector<AcVecReductionTestCase> vectorReductionTests{
|
||||
AcVecReductionTestCase{"Vector MAX", VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ, RTYPE_MAX, 0},
|
||||
AcVecReductionTestCase{"Vector MIN", VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ, RTYPE_MIN, 0},
|
||||
AcVecReductionTestCase{"Vector RMS", VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ, RTYPE_RMS, 0},
|
||||
AcVecReductionTestCase{"Vector RMS_EXP", VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ, RTYPE_RMS_EXP, 0},
|
||||
AcVecReductionTestCase{"Vector SUM", VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ, RTYPE_SUM, 0}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
for (auto& testCase : scalarReductionTests) {
|
||||
acGridReduceScal(STREAM_DEFAULT, testCase.rtype, testCase.vtxbuf, &testCase.candidate);
|
||||
}
|
||||
for (auto& testCase : vectorReductionTests) {
|
||||
acGridReduceVec(STREAM_DEFAULT, testCase.rtype, testCase.a, testCase.b, testCase.c,
|
||||
&testCase.candidate);
|
||||
}
|
||||
|
||||
acGridStoreMesh(STREAM_DEFAULT, &candidate);
|
||||
acGridQuit();
|
||||
@@ -71,10 +92,8 @@ main(void)
|
||||
acVerifyMesh(model, candidate);
|
||||
|
||||
// Check reductions
|
||||
AcReal model_reduce_res = acModelReduceScal(model, RTYPE_MAX, vtxbuf);
|
||||
Error error = acGetError(model_reduce_res, cand_reduce_res);
|
||||
error.handle = vtxbuf;
|
||||
printErrorToScreen(error);
|
||||
acVerifyScalReductions(model, scalarReductionTests.data(), scalarReductionTests.size());
|
||||
acVerifyVecReductions(model, vectorReductionTests.data(), vectorReductionTests.size());
|
||||
|
||||
acMeshDestroy(&model);
|
||||
acMeshDestroy(&candidate);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
@@ -105,6 +106,7 @@ get_max_abs_error(const VertexBufferHandle vtxbuf_handle, const AcMesh model_mes
|
||||
}
|
||||
|
||||
error.handle = vtxbuf_handle;
|
||||
strcpy(error.label, vtxbuf_names[vtxbuf_handle]);
|
||||
error.maximum_magnitude = get_maximum_magnitude(model_vtxbuf, model_mesh.info);
|
||||
error.minimum_magnitude = get_minimum_magnitude(model_vtxbuf, model_mesh.info);
|
||||
|
||||
@@ -141,7 +143,7 @@ printErrorToScreen(const Error error)
|
||||
{
|
||||
bool errors_found = false;
|
||||
|
||||
printf("\t%-15s... ", vtxbuf_names[error.handle]);
|
||||
printf("\t%-15s... ", error.label);
|
||||
if (is_acceptable(error)) {
|
||||
printf(GRN "OK! " RESET);
|
||||
}
|
||||
@@ -172,8 +174,43 @@ acVerifyMesh(const AcMesh model, const AcMesh candidate)
|
||||
printf("%s\n", errors_found ? "Failure. Found errors in one or more vertex buffers"
|
||||
: "Success. No errors found.");
|
||||
|
||||
if (errors_found)
|
||||
return AC_FAILURE;
|
||||
else
|
||||
return AC_SUCCESS;
|
||||
return errors_found ? AC_FAILURE : AC_SUCCESS;
|
||||
}
|
||||
|
||||
/** Verification function for scalar reductions*/
|
||||
AcResult
|
||||
acVerifyScalReductions(const AcMesh model, const AcScalReductionTestCase* testCases, const size_t numCases)
|
||||
{
|
||||
printf("\nTesting scalar reductions:\n");
|
||||
|
||||
bool errors_found = false;
|
||||
for (size_t i = 0; i < numCases; i++){
|
||||
AcReal model_reduction = acModelReduceScal(model, testCases[i].rtype, testCases[i].vtxbuf);
|
||||
Error error = acGetError(model_reduction, testCases[i].candidate);
|
||||
strcpy(error.label, testCases[i].label);
|
||||
errors_found |= printErrorToScreen(error);
|
||||
}
|
||||
printf("%s\n", errors_found ? "Failure. Found errors in one or more scalar reductions"
|
||||
: "Success. No errors found.");
|
||||
|
||||
return errors_found ? AC_FAILURE : AC_SUCCESS;
|
||||
}
|
||||
|
||||
/** Verification function for vector reductions*/
|
||||
AcResult
|
||||
acVerifyVecReductions(const AcMesh model, const AcVecReductionTestCase* testCases, const size_t numCases)
|
||||
{
|
||||
printf("\nTesting vector reductions:\n");
|
||||
|
||||
bool errors_found = false;
|
||||
for (size_t i = 0; i < numCases; i++){
|
||||
AcReal model_reduction = acModelReduceVec(model, testCases[i].rtype, testCases[i].a, testCases[i].b, testCases[i].c);
|
||||
Error error = acGetError(model_reduction, testCases[i].candidate);
|
||||
strcpy(error.label, testCases[i].label);
|
||||
errors_found |= printErrorToScreen(error);
|
||||
}
|
||||
printf("%s\n", errors_found ? "Failure. Found errors in one or more vector reductions"
|
||||
: "Success. No errors found.");
|
||||
|
||||
return errors_found ? AC_FAILURE : AC_SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user