f8cf59ea61d9a691b94eddfcd5e7b99fe6116760
[valse.git] / src / sources / utils.h
1 #ifndef valse_utils_H
2 #define valse_utils_H
3
4 //#include <stdint.h>
5
6 /********
7 * Types
8 *******/
9
10 typedef double Real;
11 //typedef uint32_t UInt;
12 //typedef int32_t Int;
13
14 /*******************
15 * tune parallelism
16 *******************/
17
18 // Number of OpenMP threads
19 #define OMP_NUM_THREADS 8
20
21 // CHUNK_SIZE = number of lambda values to be treated sequentially by a single core
22 #define CHUNK_SIZE 1
23
24 /*******************************
25 * Matrix and arrays indexation
26 *******************************/
27
28 // Matrix Index ; TODO? ncol unused
29 #define mi(i,j,nrow,ncol)\
30 j*nrow + i
31
32 // Array Index ; TODO? d3 unused
33 #define ai(i,j,k,d1,d2,d3)\
34 k*d1*d2 + j*d1 + i
35
36 // Array4 Index ; TODO? ...
37 #define ai4(i,j,k,m,d1,d2,d3,d4)\
38 m*d1*d2*d3 + k*d1*d2 + j*d1 + i
39
40 // Array5 Index ; TODO? ...
41 #define ai5(i,j,k,m,n,d1,d2,d3,d4,d5)\
42 n*d1*d2*d3*d4 + m*d1*d2*d3 + k*d1*d2 + j*d1 + i
43
44 /*************************
45 * Array copy & "zeroing"
46 ************************/
47
48 // Fill an array with zeros
49 #define zeroArray(array, size)\
50 {\
51 for (int u=0; u<size; u++)\
52 array[u] = 0;\
53 }
54
55 // Copy an 1D array
56 #define copyArray(array, copy, size)\
57 {\
58 for (int u=0; u<size; u++)\
59 copy[u] = array[u];\
60 }
61
62 #endif