chundoong-lab-ta/APWS23/project/util.h

28 lines
1.0 KiB
C

#pragma once
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <time.h>
/* Useful macros */
#define EXIT(status) \
do { \
exit(status); \
} while (0)
#define CHECK_ERROR(cond, fmt, ...) \
do { \
if (!(cond)) {\
printf(fmt "\n", ##__VA_ARGS__); \
EXIT(EXIT_FAILURE); \
} \
} while (false)
void print_usage_exit(int argc, char **argv);
void check_and_parse_args(int argc, char **argv);
double get_time();
void *read_binary(const char *filename, size_t *size);
void print_first_few_result(float *output, int print_max, double elapsed_time);