diff options
| author | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-17 19:07:11 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-17 20:54:41 -0400 |
| commit | 1120161286ee5c855b630bccc9e0b37bb8a3ee65 (patch) | |
| tree | 082a47491403a624a28f8b2bf8e20bbdb3f5e0e7 /dis/Matrix | |
| parent | 5aad2261f7c012aa16a93c7c5bf6bda0081658fb (diff) | |
Fix DIS coding style by running them all through clang-format
Also fixes a missing header in DISstressmarkRNG.h and the "all"
make target. No functional changes.
Diffstat (limited to 'dis/Matrix')
| -rwxr-xr-x | dis/Matrix/ver2/DISstressmarkRNG.h | 1 | ||||
| -rwxr-xr-x | dis/Matrix/ver2/matrix.c | 468 |
2 files changed, 220 insertions, 249 deletions
diff --git a/dis/Matrix/ver2/DISstressmarkRNG.h b/dis/Matrix/ver2/DISstressmarkRNG.h index 4aa2620..6243606 100755 --- a/dis/Matrix/ver2/DISstressmarkRNG.h +++ b/dis/Matrix/ver2/DISstressmarkRNG.h | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | #include <assert.h> | ||
| 1 | #include <math.h> | 2 | #include <math.h> |
| 2 | 3 | ||
| 3 | #define IA 16807 | 4 | #define IA 16807 |
diff --git a/dis/Matrix/ver2/matrix.c b/dis/Matrix/ver2/matrix.c index ffa7cb7..2b075fb 100755 --- a/dis/Matrix/ver2/matrix.c +++ b/dis/Matrix/ver2/matrix.c | |||
| @@ -1,17 +1,17 @@ | |||
| 1 | /* Please note: | 1 | /* Please note: |
| 2 | * This code is the optimized version of the first version of Matrix | 2 | * This code is the optimized version of the first version of Matrix |
| 3 | * Stressmark. It uses less temporary vectors and vsariables, thus reduce | 3 | * Stressmark. It uses less temporary vectors and vsariables, thus reduce |
| 4 | * memory allocation/deallocation overhead. the simulation is faster | 4 | * memory allocation/deallocation overhead. the simulation is faster |
| 5 | */ | 5 | */ |
| 6 | /* | 6 | /* |
| 7 | * Sample code for the DIS Matrix Stressmark | 7 | * Sample code for the DIS Matrix Stressmark |
| 8 | * | 8 | * |
| 9 | * This source code is the completely correct source code based on | 9 | * This source code is the completely correct source code based on |
| 10 | * the example codes provided by Atlantic Aerospace Division, Titan | 10 | * the example codes provided by Atlantic Aerospace Division, Titan |
| 11 | * Systems Corporation, 2000. | 11 | * Systems Corporation, 2000. |
| 12 | * | 12 | * |
| 13 | * If you just compile and generate the executables from this source | 13 | * If you just compile and generate the executables from this source |
| 14 | * code, this code would be enough. However, if you wish to get a complete | 14 | * code, this code would be enough. However, if you wish to get a complete |
| 15 | * understanding of this stressmark, it is strongly suggested that you | 15 | * understanding of this stressmark, it is strongly suggested that you |
| 16 | * read the Benchmark Analysis and Specifications Document Version 1.0 | 16 | * read the Benchmark Analysis and Specifications Document Version 1.0 |
| 17 | * before going on since the detailed comments are given in this documents. | 17 | * before going on since the detailed comments are given in this documents. |
| @@ -22,37 +22,37 @@ | |||
| 22 | * The Sparse Matrix Storage is implemented by Compact Row Storage Scheme | 22 | * The Sparse Matrix Storage is implemented by Compact Row Storage Scheme |
| 23 | * In the code, the data is first generated by randomNonzeroFloat() | 23 | * In the code, the data is first generated by randomNonzeroFloat() |
| 24 | * the data is first stored in a full-space matrix with size of dim*dim | 24 | * the data is first stored in a full-space matrix with size of dim*dim |
| 25 | * then the data is transfered to the Compact Row Matrix, | 25 | * then the data is transfered to the Compact Row Matrix, |
| 26 | * the data value is kept in *value, | 26 | * the data value is kept in *value, |
| 27 | * the columns corresponding to the value are stored in *col_ind, | 27 | * the columns corresponding to the value are stored in *col_ind, |
| 28 | * the start element of each row is stored in *row_start. | 28 | * the start element of each row is stored in *row_start. |
| 29 | */ | 29 | */ |
| 30 | 30 | ||
| 31 | /* | 31 | /* |
| 32 | * Please note: | 32 | * Please note: |
| 33 | * the total number of data is numberNonzero +dim | 33 | * the total number of data is numberNonzero +dim |
| 34 | * among which, NumberNonzero because this is symmetric matrix | 34 | * among which, NumberNonzero because this is symmetric matrix |
| 35 | * dim because the diagonal elements | 35 | * dim because the diagonal elements |
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | #include <stdio.h> | 38 | #include "DISstressmarkRNG.h" |
| 39 | #include "extra.h" | ||
| 40 | #include <assert.h> | ||
| 39 | #include <math.h> | 41 | #include <math.h> |
| 42 | #include <stdio.h> | ||
| 40 | #include <stdlib.h> | 43 | #include <stdlib.h> |
| 41 | #include <time.h> | 44 | #include <time.h> |
| 42 | #include <assert.h> | ||
| 43 | #include "DISstressmarkRNG.h" | ||
| 44 | #include "extra.h" | ||
| 45 | 45 | ||
| 46 | #define MIN_SEED -2147483647 | 46 | #define MIN_SEED -2147483647 |
| 47 | #define MAX_SEED -1 | 47 | #define MAX_SEED -1 |
| 48 | #define MIN_DIM 1 | 48 | #define MIN_DIM 1 |
| 49 | #define MAX_DIM 32768 | 49 | #define MAX_DIM 32768 |
| 50 | #define MAX_ITERATIONS 65536 | 50 | #define MAX_ITERATIONS 65536 |
| 51 | #define MIN_TOLERANCE 1e-7//0.000007 | 51 | #define MIN_TOLERANCE 1e-7 // 0.000007 |
| 52 | #define MAX_TOLERANCE 0.5 | 52 | #define MAX_TOLERANCE 0.5 |
| 53 | #define MIN_NUMBER -3.4e10/dim | 53 | #define MIN_NUMBER -3.4e10 / dim |
| 54 | #define MAX_NUMBER 3.4e10/dim | 54 | #define MAX_NUMBER 3.4e10 / dim |
| 55 | #define EPSI 1.0e-10 | 55 | #define EPSI 1.0e-10 |
| 56 | #define MIN_DIG_NUMBER 1.0e-10 | 56 | #define MIN_DIG_NUMBER 1.0e-10 |
| 57 | #define MAX_DIG_NUMBER 3.4e10 | 57 | #define MAX_DIG_NUMBER 3.4e10 |
| 58 | 58 | ||
| @@ -62,97 +62,90 @@ | |||
| 62 | 62 | ||
| 63 | static int dim; | 63 | static int dim; |
| 64 | 64 | ||
| 65 | /* | 65 | /* |
| 66 | * matrix * vector | 66 | * matrix * vector |
| 67 | */ | 67 | */ |
| 68 | 68 | ||
| 69 | void matrixMulvector(double *value, | 69 | void matrixMulvector(double *value, int *col_ind, int *row_start, |
| 70 | int *col_ind, | 70 | double *vector, double *out) { |
| 71 | int *row_start, | ||
| 72 | double *vector, | ||
| 73 | double *out) | ||
| 74 | { | ||
| 75 | int l, ll; | 71 | int l, ll; |
| 76 | double sum; | 72 | double sum; |
| 77 | int tmp_rs, tmp_re; | 73 | int tmp_rs, tmp_re; |
| 78 | 74 | ||
| 79 | for (l=0; l<dim; l++){ | 75 | for (l = 0; l < dim; l++) { |
| 80 | *(out + l) = 0; | 76 | *(out + l) = 0; |
| 81 | tmp_rs = row_start[l]; | 77 | tmp_rs = row_start[l]; |
| 82 | 78 | ||
| 83 | if (tmp_rs != -1){ | 79 | if (tmp_rs != -1) { |
| 84 | tmp_re = row_start[l+1]; /* | 80 | tmp_re = row_start[l + 1]; /* |
| 85 | *get the start and ending elements of | 81 | *get the start and ending elements of |
| 86 | * each row | 82 | * each row |
| 87 | */ | 83 | */ |
| 88 | for (ll=tmp_rs; ll<tmp_re; ll++){ | 84 | for (ll = tmp_rs; ll < tmp_re; ll++) { |
| 89 | *(out + l) += value[ll]*vector[col_ind[ll]]; | 85 | *(out + l) += value[ll] * vector[col_ind[ll]]; |
| 90 | } | 86 | } |
| 91 | } | 87 | } |
| 92 | } | 88 | } |
| 93 | return; | 89 | return; |
| 94 | } | 90 | } |
| 95 | 91 | ||
| 96 | |||
| 97 | /* | 92 | /* |
| 98 | * vector1 - vector2 | 93 | * vector1 - vector2 |
| 99 | */ | 94 | */ |
| 100 | 95 | ||
| 101 | void vectorSub(double *vector1, double *vector2, double *vector){ | 96 | void vectorSub(double *vector1, double *vector2, double *vector) { |
| 102 | 97 | ||
| 103 | int l; | 98 | int l; |
| 104 | 99 | ||
| 105 | for (l=0; l<dim; l++){ | 100 | for (l = 0; l < dim; l++) { |
| 106 | *(vector + l) = *(vector1 + l) - *(vector2 + l); | 101 | *(vector + l) = *(vector1 + l) - *(vector2 + l); |
| 107 | } | 102 | } |
| 108 | return; | 103 | return; |
| 109 | } | 104 | } |
| 110 | 105 | ||
| 111 | |||
| 112 | /* | 106 | /* |
| 113 | * vector1 + vector2 | 107 | * vector1 + vector2 |
| 114 | */ | 108 | */ |
| 115 | 109 | ||
| 116 | void vectorAdd(double *vector1, double *vector2, double *vector){ | 110 | void vectorAdd(double *vector1, double *vector2, double *vector) { |
| 117 | 111 | ||
| 118 | int l; | 112 | int l; |
| 119 | 113 | ||
| 120 | for (l=0; l<dim; l++){ | 114 | for (l = 0; l < dim; l++) { |
| 121 | *(vector + l) = *(vector1 + l) + *(vector2 + l); | 115 | *(vector + l) = *(vector1 + l) + *(vector2 + l); |
| 122 | } | 116 | } |
| 123 | return; | 117 | return; |
| 124 | } | 118 | } |
| 125 | 119 | ||
| 126 | /* | 120 | /* |
| 127 | * vector1 * vector2 | 121 | * vector1 * vector2 |
| 128 | */ | 122 | */ |
| 129 | 123 | ||
| 130 | double | ||
