common.h 1.1 KB
Newer Older
German Leon's avatar
German Leon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef _COMMON_H
#define _COMMON_H

#include <time.h>
#include <sys/time.h>

#ifdef __cplusplus
extern "C" {
#endif



#define GET_RAND_FP ( (float)rand() /   \
                     ((float)(RAND_MAX)+(float)(1)) )

#define MIN(i,j) ((i)<(j) ? (i) : (j))

typedef enum _FUNC_RETURN_CODE {
    RET_SUCCESS,
    RET_FAILURE
}func_ret_t;

typedef struct __stopwatch_t{
    struct timeval begin;
    struct timeval end;
}stopwatch;

void 
stopwatch_start(stopwatch *sw);

void 
stopwatch_stop (stopwatch *sw);

double 
get_interval_by_sec(stopwatch *sw);

int 
get_interval_by_usec(stopwatch *sw);

func_ret_t
create_matrix_from_file(float **mp, const char *filename, int *size_p);

func_ret_t
create_matrix_from_random(float **mp, int size);

func_ret_t
create_matrix(float **mp, int size);

func_ret_t
lud_verify(float *m, float *lu, int size);

void 
cmp_res (float *m, float *tmp, int matrix_dim);
void
matrix_multiply(float *inputa, float *inputb, float *output, int size);

void
matrix_duplicate(float *src, float **dst, int matrix_dim);

void
print_matrix(float *mm, int matrix_dim);

#ifdef __cplusplus
}
#endif

#endif