utilities.h 1.7 KB

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