utilities.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef UTILITIES_H
  2. #define UTILITIES_H
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <stdbool.h>
  6. #include <string.h>
  7. #include <getopt.h>
  8. #include <math.h>
  9. #include <time.h>
  10. #include "time_entry.h"
  11. #include "timer.h"
  12. typedef enum _OutputType {
  13. OUT_MILLISECONDS,
  14. OUT_SECONDS,
  15. OUT_MFLOPS,
  16. OUT_GFLOPS,
  17. OUT_THROUGHTPUT_GBS,
  18. OUT_THROUGHTPUT_MBS,
  19. OUT_NONE
  20. } OutputType;
  21. #define N_DIMS 3
  22. #define MIN_POW2 1
  23. #define MAX_POW2 20
  24. #define MIN_RUNS 1
  25. #define MAX_RUNS 100
  26. extern int N_RUNS;
  27. extern const int DIMS[N_DIMS];
  28. extern int N_POWERS_INTERVALS[N_DIMS][2];
  29. #define PRINT_DIM(dim) printf ("%dD:", dim);
  30. #define PRINT_DIM_SIZE(side_size,dim) { \
  31. printf(" %zu", side_size); while (dim != 1) { printf("x%zu", side_size);dim--; } printf("."); }
  32. #define OCL_CHECK_ERROR(error) { \
  33. if ((error) != CL_SUCCESS) fprintf (stderr, "OpenCL error <%s:%i>\n", __FILE__, __LINE__); }
  34. #define PRINT_DIMS(dim,side_size) { \
  35. if (dim == 1) { printf (" %zu", side_size); } \
  36. else if (dim == 2) { printf (" %zux%zu", side_size, side_size); } \
  37. else { printf (" %zux%zux%zu", side_size, side_size, side_size); } }
  38. void write_headers_in_file (int n_dims, int only_time, FILE *fp);
  39. void write_time_entries_in_file (TimeEntry* time_entries,
  40. int num_entries, int n_dims, int only_time,
  41. bool new_line,
  42. FILE *fp);
  43. OutputType get_output_type_by_measure(char *measure);
  44. bool get_fft_range(char *val1, char *val2, int *out_range);
  45. bool get_number_of_runs(char *val, int *out);
  46. void print_usage(char *app_name, struct option long_options[],
  47. char **options_descritions, int exit_code);
  48. double get_measurements_with_format (OutputType outputType,
  49. size_t size_bytes, double time_sec);
  50. void get_timestamp (char **ts);
  51. #endif