common.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _COMMON_H
  2. #define _COMMON_H
  3. #include <time.h>
  4. #include <sys/time.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #define GET_RAND_FP ( (float)rand() / \
  9. ((float)(RAND_MAX)+(float)(1)) )
  10. #define MIN(i,j) ((i)<(j) ? (i) : (j))
  11. typedef enum _FUNC_RETURN_CODE {
  12. RET_SUCCESS,
  13. RET_FAILURE
  14. }func_ret_t;
  15. typedef struct __stopwatch_t{
  16. struct timeval begin;
  17. struct timeval end;
  18. }stopwatch;
  19. void
  20. stopwatch_start(stopwatch *sw);
  21. void
  22. stopwatch_stop (stopwatch *sw);
  23. double
  24. get_interval_by_sec(stopwatch *sw);
  25. int
  26. get_interval_by_usec(stopwatch *sw);
  27. func_ret_t
  28. create_matrix_from_file(float **mp, const char *filename, int *size_p);
  29. func_ret_t
  30. create_matrix_from_random(float **mp, int size);
  31. func_ret_t
  32. create_matrix(float **mp, int size);
  33. func_ret_t
  34. lud_verify(float *m, float *lu, int size);
  35. void
  36. matrix_multiply(float *inputa, float *inputb, float *output, int size);
  37. void
  38. matrix_duplicate(float *src, float **dst, int matrix_dim);
  39. void
  40. print_matrix(float *mm, int matrix_dim);
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif