7#include "../offload/offload_library.h"
8#include "../offload/offload_mempool.h"
20static void print_func(
const char *msg,
int msglen,
int output_unit) {
22 if (output_unit == 0) {
31int main(
int argc,
char *argv[]) {
34 int nrequired_args = 2;
36 bool collocate =
true;
37 if (iarg < argc && strcmp(argv[iarg],
"--integrate") == 0) {
43 if (iarg < argc && strcmp(argv[iarg],
"--batch") == 0) {
50 if (argc - iarg != nrequired_args) {
51 fprintf(stderr,
"Usage: grid_miniapp.x [--integrate] [--batch "
52 "<cycles-per-block>] <cycles> <task-file>\n");
56 int cycles_per_block = 1;
57 if (batch && sscanf(argv[iarg++],
"%i", &cycles_per_block) != 1) {
58 fprintf(stderr,
"Error: Could not parse cycles per block.\n");
63 if (sscanf(argv[iarg++],
"%i", &cycles) != 1) {
64 fprintf(stderr,
"Error: Could not parse cycles.\n");
68 offload_set_chosen_device(0);
71 const double tolerance = 1e-12 * cycles;
72 const bool success =
grid_replay(argv[iarg++], cycles, collocate, batch,
73 cycles_per_block, tolerance);
77 offload_mempool_stats_print(0 , &
print_func, 0 );
80 fprintf(stderr,
"Error: Maximal difference is too large.\n");
void grid_library_finalize(void)
Finalizes the grid library.
void grid_library_init(void)
Initializes the grid library.
void grid_library_print_stats(const int fortran_comm, void(*print_func)(const char *, int, int), const int output_unit)
Prints statistics gathered by the grid library.
static void print_func(const char *msg, int msglen, int output_unit)
Wrapper for printf, passed to grid_library_print_stats.
bool grid_replay(const char *filename, const int cycles, const bool collocate, const bool batch, const int cycles_per_block, const double tolerance)
Reads a .task file, collocates/integrates it, and compares results. See grid_replay....
int main()
Unit test of the C-interface provided via libcp2k.h.