-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstuff.h
71 lines (59 loc) · 2.04 KB
/
stuff.h
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
68
69
70
71
#ifndef STUFF_H_INCLUDED
#define STUFF_H_INCLUDED
#include <stdlib.h>
#include <time.h>
#include <string.h>
// Datatype to work with
#ifdef _INT_
typedef int basetype;
#define labelelem "ints"
#define printdata(t) printf("%i", t);
#elif _DOUBLE_
typedef double basetype;
#define labelelem "doubles"
#define printdata(t) printf("%f", t);
#else
typedef float basetype; // DEFAULT
#define labelelem "floats"
#define printdata(t) printf("%f", t);
#endif
#define min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
/*
Measuring the wall time
resnfo: tipo de dato definido para abstraer la métrica de recursos a usar
timenfo: tipo de dato definido para abstraer la métrica de tiempo a usar
timestamp: abstrae función usada para tomar las muestras del tiempo transcurrido
printtime: abstrae función usada para imprimir el tiempo transcurrido
void myElapsedtime(resnfo start, resnfo end, timenfo *t): función para obtener
el tiempo transcurrido entre dos medidas
*/
#include <sys/time.h>
#include <sys/resource.h>
#ifdef _noWALL_
typedef struct rusage resnfo;
typedef struct _timenfo {
double time;
double systime;
} timenfo;
#define timestamp(sample) getrusage(RUSAGE_SELF, (sample))
#define printtime(t) printf("%15f s (%f user + %f sys) ", \
t.time + t.systime, t.time, t.systime);
#else
typedef struct timeval resnfo;
typedef double timenfo;
#define timestamp(sample) gettimeofday((sample), 0)
#define printtime(t) printf("%15f s ", t);
#endif
void get_walltime(const resnfo start, const resnfo end, timenfo *const t);
void populating_arrays(basetype arrayA[], basetype arrayB[], basetype arrayR[], const unsigned int n);
basetype check_result_and_reset(basetype array[], const unsigned int n);
void reset_matrix(basetype array[], const unsigned int n);
void adjust_params(unsigned int *n);
#endif