Now all host functions start with acHost to avoid confusion on whether the function operates on host or device memory
This commit is contained in:
@@ -98,7 +98,7 @@ main(int argc, char** argv)
|
||||
info.int_params[AC_nx] = nx;
|
||||
info.int_params[AC_ny] = ny;
|
||||
info.int_params[AC_nz] = nz;
|
||||
acUpdateBuiltinParams(&info);
|
||||
acHostUpdateBuiltinParams(&info);
|
||||
printf("Benchmark mesh dimensions: (%d, %d, %d)\n", nx, ny, nz);
|
||||
}
|
||||
else {
|
||||
@@ -118,8 +118,8 @@ main(int argc, char** argv)
|
||||
/*
|
||||
AcMesh model, candidate;
|
||||
if (pid == 0) {
|
||||
acMeshCreate(info, &model);
|
||||
acMeshCreate(info, &candidate);
|
||||
acHostMeshCreate(info, &model);
|
||||
acHostMeshCreate(info, &candidate);
|
||||
acMeshRandomize(&model);
|
||||
acMeshRandomize(&candidate);
|
||||
}*/
|
||||
@@ -130,7 +130,7 @@ main(int argc, char** argv)
|
||||
|
||||
/*
|
||||
AcMesh model;
|
||||
acMeshCreate(info, &model);
|
||||
acHostMeshCreate(info, &model);
|
||||
acMeshRandomize(&model);
|
||||
acGridLoadMesh(STREAM_DEFAULT, model);
|
||||
*/
|
||||
@@ -145,12 +145,12 @@ main(int argc, char** argv)
|
||||
|
||||
// Verify
|
||||
if (pid == 0) {
|
||||
acModelIntegrateStep(model, FLT_EPSILON);
|
||||
acHostIntegrateStep(model, FLT_EPSILON);
|
||||
acMeshApplyPeriodicBounds(&model);
|
||||
|
||||
AcResult retval = acVerifyMesh(model, candidate);
|
||||
acMeshDestroy(&model);
|
||||
acMeshDestroy(&candidate);
|
||||
acHostMeshDestroy(&model);
|
||||
acHostMeshDestroy(&candidate);
|
||||
|
||||
if (retval != AC_SUCCESS) {
|
||||
fprintf(stderr, "Failures found, benchmark invalid. Skipping\n");
|
||||
|
@@ -31,12 +31,12 @@ main(void)
|
||||
|
||||
// Alloc
|
||||
AcMesh model, candidate;
|
||||
acMeshCreate(info, &model);
|
||||
acMeshCreate(info, &candidate);
|
||||
acHostMeshCreate(info, &model);
|
||||
acHostMeshCreate(info, &candidate);
|
||||
|
||||
// Init
|
||||
acMeshRandomize(&model);
|
||||
acMeshApplyPeriodicBounds(&model);
|
||||
acHostMeshRandomize(&model);
|
||||
acHostMeshApplyPeriodicBounds(&model);
|
||||
|
||||
// Verify that the mesh was loaded and stored correctly
|
||||
acInit(info);
|
||||
@@ -55,8 +55,8 @@ main(void)
|
||||
|
||||
// Destroy
|
||||
acQuit();
|
||||
acMeshDestroy(&model);
|
||||
acMeshDestroy(&candidate);
|
||||
acHostMeshDestroy(&model);
|
||||
acHostMeshDestroy(&candidate);
|
||||
|
||||
puts("cpptest complete.");
|
||||
return EXIT_SUCCESS;
|
||||
|
@@ -30,12 +30,12 @@ main(void)
|
||||
|
||||
// Alloc
|
||||
AcMesh model, candidate;
|
||||
acMeshCreate(info, &model);
|
||||
acMeshCreate(info, &candidate);
|
||||
acHostMeshCreate(info, &model);
|
||||
acHostMeshCreate(info, &candidate);
|
||||
|
||||
// Init
|
||||
acMeshRandomize(&model);
|
||||
acMeshApplyPeriodicBounds(&model);
|
||||
acHostMeshRandomize(&model);
|
||||
acHostMeshApplyPeriodicBounds(&model);
|
||||
|
||||
// Verify that the mesh was loaded and stored correctly
|
||||
acInit(info);
|
||||
@@ -46,6 +46,7 @@ main(void)
|
||||
// Attempt to integrate and check max and min
|
||||
printf("Integrating... ");
|
||||
acIntegrate(FLT_EPSILON);
|
||||
|
||||
printf("Done.\nVTXBUF ranges after one integration step:\n");
|
||||
for (size_t i = 0; i < NUM_VTXBUF_HANDLES; ++i)
|
||||
printf("\t%-15s... [%.3g, %.3g]\n", vtxbuf_names[i], //
|
||||
@@ -54,8 +55,8 @@ main(void)
|
||||
|
||||
// Destroy
|
||||
acQuit();
|
||||
acMeshDestroy(&model);
|
||||
acMeshDestroy(&candidate);
|
||||
acHostMeshDestroy(&model);
|
||||
acHostMeshDestroy(&candidate);
|
||||
|
||||
puts("ctest complete.");
|
||||
return EXIT_SUCCESS;
|
||||
|
@@ -14,7 +14,7 @@ program pc
|
||||
info%int_params(AC_nx + 1) = 128
|
||||
info%int_params(AC_ny + 1) = 128
|
||||
info%int_params(AC_nz + 1) = 128
|
||||
call acupdatebuiltinparams(info)
|
||||
call achostupdatebuiltinparams(info)
|
||||
|
||||
call acdevicecreate(0, info, device)
|
||||
call acdeviceprintinfo(device)
|
||||
|
@@ -47,8 +47,8 @@ main(void)
|
||||
|
||||
AcMesh model, candidate;
|
||||
if (pid == 0) {
|
||||
acMeshCreate(info, &model);
|
||||
acMeshCreate(info, &candidate);
|
||||
acHostMeshCreate(info, &model);
|
||||
acHostMeshCreate(info, &candidate);
|
||||
acMeshRandomize(&model);
|
||||
acMeshRandomize(&candidate);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ main(void)
|
||||
acGridPeriodicBoundconds(STREAM_DEFAULT);
|
||||
acGridStoreMesh(STREAM_DEFAULT, &candidate);
|
||||
if (pid == 0) {
|
||||
acModelIntegrateStep(model, FLT_EPSILON);
|
||||
acHostIntegrateStep(model, FLT_EPSILON);
|
||||
acMeshApplyPeriodicBounds(&model);
|
||||
const AcResult res = acVerifyMesh("Integration", model, candidate);
|
||||
ERRCHK_ALWAYS(res == AC_SUCCESS);
|
||||
@@ -93,10 +93,10 @@ main(void)
|
||||
AcReal candval;
|
||||
acGridReduceScal(STREAM_DEFAULT, (ReductionType)i, v0, &candval);
|
||||
if (pid == 0) {
|
||||
const AcReal modelval = acModelReduceScal(model, (ReductionType)i, v0);
|
||||
const AcReal modelval = acHostReduceScal(model, (ReductionType)i, v0);
|
||||
Error error = acGetError(modelval, candval);
|
||||
error.maximum_magnitude = acModelReduceScal(model, RTYPE_MAX, v0);
|
||||
error.minimum_magnitude = acModelReduceScal(model, RTYPE_MIN, v0);
|
||||
error.maximum_magnitude = acHostReduceScal(model, RTYPE_MAX, v0);
|
||||
error.minimum_magnitude = acHostReduceScal(model, RTYPE_MIN, v0);
|
||||
ERRCHK_ALWAYS(acEvalError(rtype_names[i], error));
|
||||
}
|
||||
}
|
||||
@@ -114,17 +114,17 @@ main(void)
|
||||
AcReal candval;
|
||||
acGridReduceVec(STREAM_DEFAULT, (ReductionType)i, v0, v1, v2, &candval);
|
||||
if (pid == 0) {
|
||||
const AcReal modelval = acModelReduceVec(model, (ReductionType)i, v0, v1, v2);
|
||||
const AcReal modelval = acHostReduceVec(model, (ReductionType)i, v0, v1, v2);
|
||||
Error error = acGetError(modelval, candval);
|
||||
error.maximum_magnitude = acModelReduceVec(model, RTYPE_MAX, v0, v1, v2);
|
||||
error.minimum_magnitude = acModelReduceVec(model, RTYPE_MIN, v0, v1, v1);
|
||||
error.maximum_magnitude = acHostReduceVec(model, RTYPE_MAX, v0, v1, v2);
|
||||
error.minimum_magnitude = acHostReduceVec(model, RTYPE_MIN, v0, v1, v1);
|
||||
ERRCHK_ALWAYS(acEvalError(rtype_names[i], error));
|
||||
}
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
acMeshDestroy(&model);
|
||||
acMeshDestroy(&candidate);
|
||||
acHostMeshDestroy(&model);
|
||||
acHostMeshDestroy(&candidate);
|
||||
}
|
||||
|
||||
acGridQuit();
|
||||
|
@@ -576,7 +576,7 @@ acmesh_init_to(const InitType& init_type, AcMesh* mesh)
|
||||
|
||||
switch (init_type) {
|
||||
case INIT_TYPE_RANDOM: {
|
||||
acMeshClear(mesh);
|
||||
acHostMeshClear(mesh);
|
||||
const AcReal range = AcReal(0.01);
|
||||
for (int w = 0; w < NUM_VTXBUF_HANDLES; ++w)
|
||||
for (int i = 0; i < n; ++i)
|
||||
@@ -585,14 +585,14 @@ acmesh_init_to(const InitType& init_type, AcMesh* mesh)
|
||||
break;
|
||||
}
|
||||
case INIT_TYPE_GAUSSIAN_RADIAL_EXPL:
|
||||
acMeshClear(mesh);
|
||||
acVertexBufferSet(VTXBUF_LNRHO, mesh->info.real_params[AC_ampl_lnrho], mesh);
|
||||
acHostMeshClear(mesh);
|
||||
acHostVertexBufferSet(VTXBUF_LNRHO, mesh->info.real_params[AC_ampl_lnrho], mesh);
|
||||
// acmesh_init_to(INIT_TYPE_RANDOM, mesh);
|
||||
gaussian_radial_explosion(mesh);
|
||||
|
||||
break;
|
||||
case INIT_TYPE_XWAVE:
|
||||
acMeshClear(mesh);
|
||||
acHostMeshClear(mesh);
|
||||
acmesh_init_to(INIT_TYPE_RANDOM, mesh);
|
||||
for (int k = 0; k < mz; k++) {
|
||||
for (int j = 0; j < my; j++) {
|
||||
@@ -605,24 +605,24 @@ acmesh_init_to(const InitType& init_type, AcMesh* mesh)
|
||||
}
|
||||
break;
|
||||
case INIT_TYPE_SIMPLE_CORE:
|
||||
acMeshClear(mesh);
|
||||
acHostMeshClear(mesh);
|
||||
simple_uniform_core(mesh);
|
||||
break;
|
||||
case INIT_TYPE_VEDGE:
|
||||
acMeshClear(mesh);
|
||||
acHostMeshClear(mesh);
|
||||
inflow_vedge_freefall(mesh);
|
||||
break;
|
||||
case INIT_TYPE_VEDGEX:
|
||||
acMeshClear(mesh);
|
||||
acHostMeshClear(mesh);
|
||||
inflow_freefall_x(mesh);
|
||||
break;
|
||||
case INIT_TYPE_RAYLEIGH_TAYLOR:
|
||||
acMeshClear(mesh);
|
||||
acHostMeshClear(mesh);
|
||||
inflow_freefall_x(mesh);
|
||||
lnrho_step(mesh);
|
||||
break;
|
||||
case INIT_TYPE_ABC_FLOW: {
|
||||
acMeshClear(mesh);
|
||||
acHostMeshClear(mesh);
|
||||
acmesh_init_to(INIT_TYPE_RANDOM, mesh);
|
||||
for (int k = nz_min; k < nz_max; k++) {
|
||||
for (int j = ny_min; j < ny_max; j++) {
|
||||
|
@@ -199,9 +199,9 @@ print_diagnostics_host(const AcMesh mesh, const int step, const AcReal dt, const
|
||||
const int max_name_width = 16;
|
||||
|
||||
// Calculate rms, min and max from the velocity vector field
|
||||
buf_max = acModelReduceVec(mesh, RTYPE_MAX, VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ);
|
||||
buf_min = acModelReduceVec(mesh, RTYPE_MIN, VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ);
|
||||
buf_rms = acModelReduceVec(mesh, RTYPE_RMS, VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ);
|
||||
buf_max = acHostReduceVec(mesh, RTYPE_MAX, VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ);
|
||||
buf_min = acHostReduceVec(mesh, RTYPE_MIN, VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ);
|
||||
buf_rms = acHostReduceVec(mesh, RTYPE_RMS, VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ);
|
||||
|
||||
// MV: The ordering in the earlier version was wrong in terms of variable
|
||||
// MV: name and its diagnostics.
|
||||
@@ -213,9 +213,9 @@ print_diagnostics_host(const AcMesh mesh, const int step, const AcReal dt, const
|
||||
|
||||
// Calculate rms, min and max from the variables as scalars
|
||||
for (int i = 0; i < NUM_VTXBUF_HANDLES; ++i) {
|
||||
buf_max = acModelReduceScal(mesh, RTYPE_MAX, VertexBufferHandle(i));
|
||||
buf_min = acModelReduceScal(mesh, RTYPE_MIN, VertexBufferHandle(i));
|
||||
buf_rms = acModelReduceScal(mesh, RTYPE_RMS, VertexBufferHandle(i));
|
||||
buf_max = acHostReduceScal(mesh, RTYPE_MAX, VertexBufferHandle(i));
|
||||
buf_min = acHostReduceScal(mesh, RTYPE_MIN, VertexBufferHandle(i));
|
||||
buf_rms = acHostReduceScal(mesh, RTYPE_RMS, VertexBufferHandle(i));
|
||||
|
||||
printf(" %*s: min %.3e,\trms %.3e,\tmax %.3e\n", max_name_width, vtxbuf_names[i],
|
||||
double(buf_min), double(buf_rms), double(buf_max));
|
||||
@@ -330,7 +330,7 @@ main(int argc, char** argv)
|
||||
|
||||
AcMesh mesh;
|
||||
if (pid == 0) {
|
||||
acMeshCreate(info, &mesh);
|
||||
acHostMeshCreate(info, &mesh);
|
||||
acmesh_init_to(INIT_TYPE_GAUSSIAN_RADIAL_EXPL, &mesh);
|
||||
}
|
||||
acGridInit(info);
|
||||
@@ -362,7 +362,7 @@ main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
if (pid == 0)
|
||||
acMeshDestroy(&mesh);
|
||||
acHostMeshDestroy(&mesh);
|
||||
|
||||
acGridQuit();
|
||||
/////////////// Simple example END
|
||||
@@ -376,7 +376,7 @@ main(int argc, char** argv)
|
||||
if (argc == 3 && (!strcmp(argv[1], "-c") || !strcmp(argv[1], "--config"))) {
|
||||
acLoadConfig(argv[2], &info);
|
||||
load_config(argv[2], &info);
|
||||
acUpdateBuiltinParams(&info);
|
||||
acHostUpdateBuiltinParams(&info);
|
||||
}
|
||||
else {
|
||||
printf("Usage: ./ac_run\n");
|
||||
@@ -388,7 +388,7 @@ main(int argc, char** argv)
|
||||
else {
|
||||
acLoadConfig(AC_DEFAULT_CONFIG, &info);
|
||||
load_config(AC_DEFAULT_CONFIG, &info);
|
||||
acUpdateBuiltinParams(&info);
|
||||
acHostUpdateBuiltinParams(&info);
|
||||
}
|
||||
|
||||
const int start_step = info.int_params[AC_start_step];
|
||||
@@ -406,7 +406,7 @@ main(int argc, char** argv)
|
||||
AcMesh mesh;
|
||||
///////////////////////////////// PROC 0 BLOCK START ///////////////////////////////////////////
|
||||
if (pid == 0) {
|
||||
acMeshCreate(info, &mesh);
|
||||
acHostMeshCreate(info, &mesh);
|
||||
// TODO: This need to be possible to define in astaroth.conf
|
||||
acmesh_init_to(INIT_TYPE_GAUSSIAN_RADIAL_EXPL, &mesh);
|
||||
// acmesh_init_to(INIT_TYPE_SIMPLE_CORE, mesh); //Initial condition for a collapse test
|
||||
@@ -564,7 +564,7 @@ main(int argc, char** argv)
|
||||
|
||||
acGridQuit();
|
||||
if (pid == 0)
|
||||
acMeshDestroy(&mesh);
|
||||
acHostMeshDestroy(&mesh);
|
||||
fclose(diag_file);
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user