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:
@@ -31,7 +31,10 @@ extern "C" {
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define ERROR_LABEL_LENGTH 30
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
char label[ERROR_LABEL_LENGTH];
|
||||||
VertexBufferHandle handle;
|
VertexBufferHandle handle;
|
||||||
AcReal model;
|
AcReal model;
|
||||||
AcReal candidate;
|
AcReal candidate;
|
||||||
@@ -42,6 +45,22 @@ typedef struct {
|
|||||||
AcReal minimum_magnitude;
|
AcReal minimum_magnitude;
|
||||||
} Error;
|
} 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 */
|
/** TODO comment */
|
||||||
Error acGetError(AcReal model, AcReal candidate);
|
Error acGetError(AcReal model, AcReal candidate);
|
||||||
|
|
||||||
@@ -76,17 +95,20 @@ AcResult acMeshClear(AcMesh* mesh);
|
|||||||
AcResult acModelIntegrateStep(AcMesh mesh, const AcReal dt);
|
AcResult acModelIntegrateStep(AcMesh mesh, const AcReal dt);
|
||||||
|
|
||||||
/** TODO */
|
/** TODO */
|
||||||
AcReal
|
AcReal acModelReduceScal(const AcMesh mesh, const ReductionType rtype, const VertexBufferHandle a);
|
||||||
acModelReduceScal(const AcMesh mesh, const ReductionType rtype, const VertexBufferHandle a);
|
|
||||||
|
|
||||||
/** TODO */
|
/** TODO */
|
||||||
AcReal
|
AcReal acModelReduceVec(const AcMesh mesh, const ReductionType rtype, const VertexBufferHandle a, const VertexBufferHandle b, const VertexBufferHandle c);
|
||||||
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 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
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#if AC_MPI_ENABLED
|
#if AC_MPI_ENABLED
|
||||||
|
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
int
|
int
|
||||||
main(void)
|
main(void)
|
||||||
@@ -53,12 +54,32 @@ main(void)
|
|||||||
acGridIntegrate(STREAM_DEFAULT, FLT_EPSILON);
|
acGridIntegrate(STREAM_DEFAULT, FLT_EPSILON);
|
||||||
acGridPeriodicBoundconds(STREAM_DEFAULT);
|
acGridPeriodicBoundconds(STREAM_DEFAULT);
|
||||||
|
|
||||||
// Do reductions
|
// clang-format off
|
||||||
AcReal cand_reduce_res = 0;
|
// Define scalar reduction tests here
|
||||||
VertexBufferHandle vtxbuf = VTXBUF_UUX;
|
std::vector<AcScalReductionTestCase> scalarReductionTests{
|
||||||
ReductionType rtype = RTYPE_MAX;
|
AcScalReductionTestCase{"Scalar MAX", VTXBUF_UUX, RTYPE_MAX, 0},
|
||||||
acGridReduceScal(STREAM_DEFAULT, rtype, vtxbuf, &cand_reduce_res); // TODO
|
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);
|
acGridStoreMesh(STREAM_DEFAULT, &candidate);
|
||||||
acGridQuit();
|
acGridQuit();
|
||||||
@@ -71,10 +92,8 @@ main(void)
|
|||||||
acVerifyMesh(model, candidate);
|
acVerifyMesh(model, candidate);
|
||||||
|
|
||||||
// Check reductions
|
// Check reductions
|
||||||
AcReal model_reduce_res = acModelReduceScal(model, RTYPE_MAX, vtxbuf);
|
acVerifyScalReductions(model, scalarReductionTests.data(), scalarReductionTests.size());
|
||||||
Error error = acGetError(model_reduce_res, cand_reduce_res);
|
acVerifyVecReductions(model, vectorReductionTests.data(), vectorReductionTests.size());
|
||||||
error.handle = vtxbuf;
|
|
||||||
printErrorToScreen(error);
|
|
||||||
|
|
||||||
acMeshDestroy(&model);
|
acMeshDestroy(&model);
|
||||||
acMeshDestroy(&candidate);
|
acMeshDestroy(&candidate);
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||||
#define min(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;
|
error.handle = vtxbuf_handle;
|
||||||
|
strcpy(error.label, vtxbuf_names[vtxbuf_handle]);
|
||||||
error.maximum_magnitude = get_maximum_magnitude(model_vtxbuf, model_mesh.info);
|
error.maximum_magnitude = get_maximum_magnitude(model_vtxbuf, model_mesh.info);
|
||||||
error.minimum_magnitude = get_minimum_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;
|
bool errors_found = false;
|
||||||
|
|
||||||
printf("\t%-15s... ", vtxbuf_names[error.handle]);
|
printf("\t%-15s... ", error.label);
|
||||||
if (is_acceptable(error)) {
|
if (is_acceptable(error)) {
|
||||||
printf(GRN "OK! " RESET);
|
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"
|
printf("%s\n", errors_found ? "Failure. Found errors in one or more vertex buffers"
|
||||||
: "Success. No errors found.");
|
: "Success. No errors found.");
|
||||||
|
|
||||||
if (errors_found)
|
return errors_found ? AC_FAILURE : AC_SUCCESS;
|
||||||
return AC_FAILURE;
|
}
|
||||||
else
|
|
||||||
return 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