Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Google-TPU
BLAS-join
Commits
9a476f7b
Commit
9a476f7b
authored
Dec 11, 2018
by
Martin Perdacher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update random number generator
parent
70ba6f69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
11 deletions
+23
-11
cmake/main.cpp
cmake/main.cpp
+1
-1
cmake/util/dataIo.cpp
cmake/util/dataIo.cpp
+19
-9
cmake/util/dataIo.h
cmake/util/dataIo.h
+3
-1
No files found.
cmake/main.cpp
View file @
9a476f7b
...
@@ -57,7 +57,7 @@ int main(int argc, char** argv) {
...
@@ -57,7 +57,7 @@ int main(int argc, char** argv) {
if
(
strcmp
(
filename
,
""
)
==
0
)
{
if
(
strcmp
(
filename
,
""
)
==
0
)
{
// printf("random_init\n");
// printf("random_init\n");
random_init
(
x
,
N
,
D
);
random_init
_unif
(
x
,
N
,
D
);
}
else
{
}
else
{
// printf("read_file\n");
// printf("read_file\n");
read_file
(
x
,
N
,
D
,
filename
,
isBinary
);
read_file
(
x
,
N
,
D
,
filename
,
isBinary
);
...
...
cmake/util/dataIo.cpp
View file @
9a476f7b
#include "dataIo.h"
#include "dataIo.h"
void
random_init
(
double
*
array
,
const
int
N
,
const
int
D
){
void
random_init
_unif
(
double
*
array
,
const
int
N
,
const
int
D
){
#pragma omp parallel
#pragma omp parallel
{
{
int
tId
=
omp_get_thread_num
();
int
tId
=
omp_get_thread_num
();
short
unsigned
seed
[
3
];
VSLStreamStatePtr
stream
;
seed
[
0
]
=
(((
tId
*
tId
+
15
)
*
3
)
/
7
);
const
int
SEED
=
(
tId
+
15
)
*
3
;
seed
[
1
]
=
(((
tId
*
tId
+
13
)
*
2
)
/
3
);
const
double
LOWER_BOUND
=
0.0
;
seed
[
2
]
=
tId
;
const
double
UPPER_BOUND
=
1.0
;
int
errcode
=
vslNewStream
(
&
stream
,
VSL_BRNG_MCG31
,
SEED
);
if
(
errcode
!=
VSL_ERROR_OK
&&
errcode
!=
VSL_STATUS_OK
){
printf
(
"vslNewStream error. dataIo.cpp line 9.
\n
"
);
exit
(
1
);
}
#pragma omp for collapse(2)
#pragma ivdep
#pragma omp for
for
(
int
i
=
0
;
i
<
N
;
i
++
){
for
(
int
i
=
0
;
i
<
N
;
i
++
){
for
(
int
j
=
0
;
j
<
D
;
j
++
)
// generate D uniform distributed values
array
[
i
*
N
+
j
]
=
erand48
(
seed
);
errcode
=
vdRngUniform
(
VSL_RNG_METHOD_UNIFORM_STD
,
stream
,
D
,
&
array
[
i
*
N
],
LOWER_BOUND
,
UPPER_BOUND
);
if
(
errcode
!=
VSL_ERROR_OK
&&
errcode
!=
VSL_STATUS_OK
){
printf
(
"vslNewStream error. dataIo.cpp line 20.
\n
"
);
exit
(
1
);
}
}
}
}
}
}
}
...
...
cmake/util/dataIo.h
View file @
9a476f7b
...
@@ -8,9 +8,11 @@
...
@@ -8,9 +8,11 @@
#include <omp.h>
#include <omp.h>
#include "mkl_vsl.h"
#define MAX_LINE_LENGTH 2049
#define MAX_LINE_LENGTH 2049
void
random_init
(
double
*
array
,
const
int
N
,
const
int
D
);
void
random_init
_unif
(
double
*
array
,
const
int
N
,
const
int
D
);
void
read_file
(
double
*
array
,
const
int
N
,
const
int
D
,
char
filename
[],
const
bool
IS_BINARY
);
void
read_file
(
double
*
array
,
const
int
N
,
const
int
D
,
char
filename
[],
const
bool
IS_BINARY
);
void
save_binary_file
(
double
*
array
,
const
int
N
,
const
int
D
,
char
filename
[]);
void
save_binary_file
(
double
*
array
,
const
int
N
,
const
int
D
,
char
filename
[]);
void
save_text_file
(
double
*
array
,
const
int
N
,
const
int
D
,
char
filename
[]);
void
save_text_file
(
double
*
array
,
const
int
N
,
const
int
D
,
char
filename
[]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment