Last change
on this file since 919 was
843,
checked in by devigne, 10 years ago
|
RWT Commit : Add soft directory.
Soft directory contains scripts used to validate the RWT protocol
|
File size:
791 bytes
|
Rev | Line | |
---|
[843] | 1 | |
---|
| 2 | #ifndef _functions_h_ |
---|
| 3 | #define _functions_h_ |
---|
| 4 | |
---|
| 5 | #include <math.h> |
---|
| 6 | #include <stdlib.h> |
---|
| 7 | #include <stdio.h> |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | static int mylog2(size_t v) { |
---|
| 11 | static const size_t b[] = { 0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000 }; |
---|
| 12 | static const size_t S[] = { 1, 2, 4, 8, 16 }; |
---|
| 13 | int i; |
---|
| 14 | register size_t r = 0; |
---|
| 15 | for (i = 4; i >= 0; i--) { |
---|
| 16 | if (v & b[i]) { |
---|
| 17 | v >>= S[i]; |
---|
| 18 | r |= S[i]; |
---|
| 19 | } |
---|
| 20 | } |
---|
| 21 | return r + 1; |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | int randint(int a, int b) { |
---|
| 25 | int range = b - a + 1; |
---|
| 26 | int res = rand() % range; |
---|
| 27 | return res + a; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | int index2realindex(int var_index, int nb_diff_CL, int cache_lines, int line_size) { |
---|
| 32 | int index = var_index % (nb_diff_CL * line_size) + (cache_lines * line_size)*(var_index / (line_size * nb_diff_CL)); |
---|
| 33 | return index; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.