Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Damir Mustafin
lo3
Commits
7b9aaf10
Commit
7b9aaf10
authored
Jan 14, 2020
by
Kostya
Committed by
Vladislav Perepelkin
Jan 14, 2020
Browse files
fix
parent
cb5d582f
Changes
19
Hide whitespace changes
Inline
Side-by-side
examples/iade_rb_cg_1d/program.cpp
View file @
7b9aaf10
...
...
@@ -6,7 +6,7 @@
#include
<stdlib.h>
#include
<unistd.h>
#define
PI 3.14159265358979323846
constexpr
PI
3.14159265358979323846
struct
task_parameters
{
...
...
include/common.h
View file @
7b9aaf10
...
...
@@ -6,13 +6,13 @@
#include
<stdexcept>
#include
<string>
#define STYLE_RESET
"\033[0m"
// default color
#define STYLE_BLUE_BOLD "\033[34;1m"
// blue color with bold text
#define STYLE_GREEN_BOLD "\033[1;32m"
// green color with bold text
#define STYLE_BOLD
"\033[1m"
// default color with bold text
#define STYLE_GREY
"\033[2m"
// semi bright color
#define STYLE_YELLOW_BOLD "\033[1;33m"
// yellow color with bold text
#define STYLE_RED_BOLD
"\033[1;31m"
// red color with bold text
#define STYLE_RESET
"\033[0m"
// default color
#define STYLE_BLUE_BOLD "\033[34;1m"
// blue color with bold text
#define STYLE_GREEN_BOLD "\033[1;32m"
// green color with bold text
#define STYLE_BOLD
"\033[1m"
// default color with bold text
#define STYLE_GREY
"\033[2m"
// semi bright color
#define STYLE_YELLOW_BOLD "\033[1;33m"
// yellow color with bold text
#define STYLE_RED_BOLD
"\033[1;31m"
// red color with bold text
#define VERSION_RTS "0.6"
#define SHOW_EXEC_TIME if(false)
...
...
@@ -31,24 +31,24 @@
#define NOTE(msg) {\
assert(!_prefix.empty());\
fprintf(stderr, "%s" STYLE_GREEN_BOLD "NOTE:" STYLE_RESET
""
STYLE_BOLD " %s" STYLE_RESET
" "
\
""
STYLE_BOLD "%s:%d" STYLE_RESET
"\n"
, _prefix.c_str(), \
fprintf(stderr, "%s
" STYLE_GREEN_BOLD "NOTE:" STYLE_RESET STYLE_BOLD " %s
" STYLE_RESET \
STYLE_BOLD "%s:%d
\n
" STYLE_RESET, _prefix.c_str(), \
std::string(msg).c_str(), \
__FILE__, __LINE__);\
}
#define WARN(msg) {\
assert(!_prefix.empty());\
fprintf(stderr, "%s" STYLE_YELLOW_BOLD "WARNING:" STYLE_RESET
""
STYLE_BOLD " %s" STYLE_RESET
" "
\
""
STYLE_BOLD "%s:%d" STYLE_RESET
"\n"
, _prefix.c_str(), \
fprintf(stderr, "%s
" STYLE_YELLOW_BOLD "WARNING:
" STYLE_RESET STYLE_BOLD " %s
" STYLE_RESET \
STYLE_BOLD "%s:%d
\n
" STYLE_RESET, _prefix.c_str(), \
std::string(msg).c_str(), \
__FILE__, __LINE__);\
}
#define ERROR(msg) {\
assert(!_prefix.empty());\
fprintf(stderr, "%s" STYLE_RED_BOLD "ERROR:" STYLE_RESET
""
STYLE_BOLD " %s" STYLE_RESET
" "
\
""
STYLE_BOLD "%s:%d" STYLE_RESET
"\n"
, _prefix.c_str(), \
fprintf(stderr, "%s
" STYLE_RED_BOLD "ERROR:
" STYLE_RESET STYLE_BOLD " %s
" STYLE_RESET \
STYLE_BOLD "%s:%d
\n
" STYLE_RESET, _prefix.c_str(), \
std::string(msg).c_str(), \
__FILE__, __LINE__);\
}
...
...
@@ -56,7 +56,7 @@
#define ABORT(msg) {\
assert(!_prefix.empty());\
ERROR(msg) \
fprintf(stderr, "%s" STYLE_RED_BOLD "ABORT" STYLE_RESET
"\n"
, _prefix.c_str()); \
fprintf(stderr, "%s
" STYLE_RED_BOLD "ABORT
\n
" STYLE_RESET, _prefix.c_str()); \
throw RuntimeError(__FILE__, __LINE__, msg); \
abort();\
}
...
...
src/rts/rts.cpp
View file @
7b9aaf10
...
...
@@ -85,7 +85,7 @@ int RTS::run()
SHOW_EXEC_TIME
if
(
comm_
->
is_root
())
{
printf
(
STYLE_BOLD
"NORMAL SYSTEM STOP: %lf sec"
STYLE_RESET
"
\n
"
,
printf
(
STYLE_BOLD
"NORMAL SYSTEM STOP: %lf sec
\n
"
STYLE_RESET
,
wtime
()
-
start_time
);
}
...
...
tests/03_integral/06_mxm/ucodes.cpp
View file @
7b9aaf10
...
...
@@ -4,79 +4,90 @@
using
namespace
luna
::
ucenv
;
struct
Matrix
{
struct
Matrix
{
size_t
Height
,
Width
;
double
*
Data
;
double
*
Data
;
};
void
create_matr_buf
(
OutputDF
&
out
,
const
int
&
height
,
const
int
&
width
)
{
void
create_matr_buf
(
OutputDF
&
out
,
const
int
&
height
,
const
int
&
width
)
{
out
.
create
(
2
*
sizeof
(
size_t
)
+
height
*
width
*
sizeof
(
double
));
size_t
*
data
=
static_cast
<
size_t
*>
(
out
.
get_data
());
data
[
0
]
=
height
;
data
[
1
]
=
width
;
data
[
0
]
=
height
;
data
[
1
]
=
width
;
}
void
*
shift
(
void
*
buf
,
int
ofs
)
{
return
(
void
*
)(((
char
*
)
buf
)
+
ofs
);
void
*
shift
(
void
*
buf
,
int
ofs
)
{
return
(
void
*
)(((
char
*
)
buf
)
+
ofs
);
}
void
mf_init_random
(
struct
Matrix
*
m
,
const
double
&
min_value
,
const
double
&
max_value
)
{
assert
(
m
!=
NULL
);
assert
(
max_value
>=
min_value
);
assert
(
m
->
Height
>
0
&&
m
->
Width
>
0
&&
m
->
Data
!=
NULL
);
void
mf_init_random
(
struct
Matrix
*
m
,
const
double
&
min_value
,
const
double
&
max_value
)
{
assert
(
m
!=
NULL
);
assert
(
max_value
>=
min_value
);
assert
(
m
->
Height
>
0
&&
m
->
Width
>
0
&&
m
->
Data
!=
NULL
);
for
(
size_t
i
=
0
;
i
<
m
->
Height
;
i
++
)
for
(
size_t
j
=
0
;
j
<
m
->
Width
;
j
++
)
{
m
->
Data
[
i
*
m
->
Width
+
j
]
=
min_value
+
rand
()
*
(
max_value
-
min_value
)
/
RAND_MAX
;
for
(
size_t
i
=
0
;
i
<
m
->
Height
;
i
++
)
{
for
(
size_t
j
=
0
;
j
<
m
->
Width
;
j
++
)
{
m
->
Data
[
i
*
m
->
Width
+
j
]
=
min_value
+
rand
()
*
(
max_value
-
min_value
)
/
RAND_MAX
;
}
}
}
void
attach
(
struct
Matrix
&
A
,
const
InputDF
&
a
)
{
const
size_t
*
data
=
static_cast
<
const
size_t
*>
(
a
.
get_data
());
A
.
Height
=
data
[
0
];
A
.
Width
=
data
[
1
];
A
.
Data
=
(
double
*
)(
data
+
2
);
void
attach
(
struct
Matrix
&
A
,
const
InputDF
&
a
)
{
const
size_t
*
data
=
static_cast
<
const
size_t
*>
(
a
.
get_data
());
A
.
Height
=
data
[
0
];
A
.
Width
=
data
[
1
];
A
.
Data
=
(
double
*
)(
data
+
2
);
}
extern
"C"
void
c_init
(
int
val
,
OutputDF
&
df
)
{
void
c_init
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
<
int
>
(
val
);
printf
(
"c_init: %d --> %s, size: %d
\n
"
,
val
,
df
.
getName
().
c_str
(),
(
int
)
df
.
getSize
());
}
extern
"C"
void
c_init_submatrix
(
const
char
*
/*file*/
,
int
/*row*/
,
int
/*col*/
,
int
height
,
int
width
,
OutputDF
&
dest
)
{
void
c_init_submatrix
(
const
char
*
,
int
,
int
,
int
height
,
int
width
,
OutputDF
&
dest
)
{
struct
Matrix
m
;
create_matr_buf
(
dest
,
height
,
width
);
m
.
Height
=
height
;
m
.
Width
=
width
;
const
size_t
*
data
=
static_cast
<
const
size_t
*>
(
dest
.
get_data
());
m
.
Data
=
(
double
*
)(
data
+
2
);
m
.
Height
=
height
;
m
.
Width
=
width
;
const
size_t
*
data
=
static_cast
<
const
size_t
*>
(
dest
.
get_data
());
m
.
Data
=
(
double
*
)(
data
+
2
);
mf_init_random
(
&
m
,
1
,
2
);
}
extern
"C"
void
c_copy_matrix
(
const
InputDF
&
a
,
OutputDF
&
b
)
{
void
c_copy_matrix
(
const
InputDF
&
a
,
OutputDF
&
b
)
{
b
.
copy
(
a
);
}
extern
"C"
void
c_sum_matrix
(
const
InputDF
&
a
,
const
InputDF
&
b
,
OutputDF
&
c
)
{
void
c_sum_matrix
(
const
InputDF
&
a
,
const
InputDF
&
b
,
OutputDF
&
c
)
{
struct
Matrix
A
,
B
,
C
;
attach
(
A
,
a
);
attach
(
B
,
b
);
assert
(
A
.
Height
==
B
.
Height
&&
A
.
Width
==
B
.
Width
);
assert
(
A
.
Height
==
B
.
Height
&&
A
.
Width
==
B
.
Width
);
create_matr_buf
(
c
,
A
.
Height
,
A
.
Width
);
C
.
Height
=
A
.
Height
;
C
.
Width
=
B
.
Width
;
const
size_t
*
data
=
static_cast
<
const
size_t
*>
(
c
.
get_data
());
C
.
Data
=
(
double
*
)(
data
+
2
);
for
(
size_t
i
=
0
;
i
<
C
.
Height
*
C
.
Width
;
i
++
)
C
.
Data
[
i
]
=
A
.
Data
[
i
]
+
B
.
Data
[
i
];
C
.
Height
=
A
.
Height
;
C
.
Width
=
B
.
Width
;
const
size_t
*
data
=
static_cast
<
const
size_t
*>
(
c
.
get_data
());
C
.
Data
=
(
double
*
)(
data
+
2
);
for
(
size_t
i
=
0
;
i
<
C
.
Height
*
C
.
Width
;
i
++
)
{
C
.
Data
[
i
]
=
A
.
Data
[
i
]
+
B
.
Data
[
i
];
}
}
extern
"C"
...
...
@@ -91,23 +102,18 @@ void c_mult_matrix(const InputDF &a, const InputDF &b, OutputDF &c)
create_matr_buf
(
c
,
A
.
Height
,
B
.
Width
);
const
size_t
*
data
=
static_cast
<
const
size_t
*>
(
c
.
get_data
());
double
*
Csubm
=
(
double
*
)(
data
+
2
);
/*
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
A.Height, B.Width, A.Width, 1.0,
A.Data, A.Width, B.Data, B.Width, 0.0,
Csubm, B.Width);
*/
const
size_t
*
data
=
static_cast
<
const
size_t
*>
(
c
.
get_data
());
double
*
Csubm
=
(
double
*
)(
data
+
2
);
printf
(
"A: %dx%d
\n
"
,
(
int
)
A
.
Height
,
(
int
)
A
.
Width
);
printf
(
"B: %dx%d
\n
"
,
(
int
)
B
.
Height
,
(
int
)
B
.
Width
);
for
(
size_t
i
=
0
;
i
<
A
.
Height
;
i
++
)
for
(
size_t
j
=
0
;
j
<
B
.
Width
;
j
++
)
for
(
size_t
k
=
0
;
k
<
A
.
Width
;
k
++
)
{
Csubm
[
i
*
B
.
Width
+
j
]
+=
A
.
Data
[
i
*
A
.
Width
+
k
]
*
B
.
Data
[
k
*
B
.
Width
+
j
];
for
(
size_t
i
=
0
;
i
<
A
.
Height
;
i
++
)
{
for
(
size_t
j
=
0
;
j
<
B
.
Width
;
j
++
)
{
for
(
size_t
k
=
0
;
k
<
A
.
Width
;
k
++
)
{
Csubm
[
i
*
B
.
Width
+
j
]
+=
A
.
Data
[
i
*
A
.
Width
+
k
]
*
B
.
Data
[
k
*
B
.
Width
+
j
];
}
}
}
}
tests/04_programs/basic1/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
extern
"C"
void
c_helloworld
()
{
void
c_helloworld
()
{
printf
(
"Hello world!
\n
"
);
}
tests/04_programs/basic1a/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
"ucenv.h"
extern
"C"
{
extern
"C"
{
void
c_init
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_init: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
());
}
void
c_in
i
t
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_i
nit: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
()
);
}
void
c_i
pri
nt
(
int
val
)
{
printf
(
"c_i
print %d
\n
"
,
val
);
}
void
c_iprint
(
int
val
)
{
printf
(
"c_iprint %d
\n
"
,
val
);
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
\ No newline at end of file
tests/04_programs/basic1b/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
"ucenv.h"
extern
"C"
{
extern
"C"
{
void
c_init
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_init: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
());
}
void
c_in
i
t
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_i
nit: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
()
);
}
void
c_i
pri
nt
(
int
val
)
{
printf
(
"c_i
print %d
\n
"
,
val
);
}
void
c_iprint
(
int
val
)
{
printf
(
"c_iprint %d
\n
"
,
val
);
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
\ No newline at end of file
tests/04_programs/basic1c/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
"ucenv.h"
extern
"C"
{
extern
"C"
{
void
c_init
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_init: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
());
}
void
c_in
i
t
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_i
nit: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
()
);
}
void
c_i
pri
nt
(
int
val
)
{
printf
(
"c_i
print %d
\n
"
,
val
);
}
void
c_iprint
(
int
val
)
{
printf
(
"c_iprint %d
\n
"
,
val
);
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
\ No newline at end of file
tests/04_programs/basic1d/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
"ucenv.h"
extern
"C"
{
extern
"C"
{
void
c_init
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_init: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
());
}
void
c_in
i
t
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_i
nit: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
()
);
}
void
c_i
pri
nt
(
int
val
)
{
printf
(
"c_i
print %d
\n
"
,
val
);
}
void
c_iprint
(
int
val
)
{
printf
(
"c_iprint %d
\n
"
,
val
);
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
\ No newline at end of file
tests/04_programs/basic2/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
"ucenv.h"
extern
"C"
{
extern
"C"
{
void
c_init
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_init: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
());
}
void
c_in
i
t
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_i
nit: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
()
);
}
void
c_i
pri
nt
(
int
val
)
{
printf
(
"c_i
print %d
\n
"
,
val
);
}
void
c_iprint
(
int
val
)
{
printf
(
"c_iprint %d
\n
"
,
val
);
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
void
c_print
(
const
InputDF
&
df
)
{
printf
(
"c_print: %d
\n
"
,
df
.
getValue
<
int
>
());
}
}
\ No newline at end of file
tests/04_programs/basic3/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
"ucenv.h"
extern
"C"
{
extern
"C"
{
void
c_init
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_init: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
());
}
void
c_init
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_init: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
());
}
void
c_iprint
(
int
val
)
{
printf
(
"c_iprint %d
\n
"
,
val
);
}
}
void
c_iprint
(
int
val
)
{
printf
(
"c_iprint %d
\n
"
,
val
);
}
}
\ No newline at end of file
tests/04_programs/basic4/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
"ucenv.h"
extern
"C"
{
extern
"C"
{
void
c_init
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_init: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
());
}
void
c_in
i
t
(
int
val
,
OutputDF
&
df
)
{
df
.
setValue
(
val
);
printf
(
"c_i
nit: %d, size: %d
\n
"
,
val
,
(
int
)
df
.
getSize
()
);
}
void
c_i
pri
nt
(
int
val
)
{
printf
(
"c_i
print %d
\n
"
,
val
);
}
void
c_iprint
(
int
val
)
{
printf
(
"c_iprint %d
\n
"
,
val
);
}
void
c_rprint
(
double
val
)
{
printf
(
"c_rprint %lf
\n
"
,
val
);
}
}
void
c_rprint
(
double
val
)
{
printf
(
"c_rprint %lf
\n
"
,
val
);
}
}
\ No newline at end of file
tests/04_programs/basic5/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
extern
"C"
{
void
c_helloworld
()
{
printf
(
"c_Hello world!
\n
"
);
}
}
extern
"C"
{
void
c_helloworld
()
{
printf
(
"c_Hello world!
\n
"
);
}
}
\ No newline at end of file
tests/04_programs/basic6-fail/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
<cstring>
extern
"C"
{
void
c_hello
(
const
char
*
x
)
{
if
(
strlen
(
x
)
>
0
)
printf
(
"Hello, %s!
\n
"
,
x
);
else
printf
(
"Hello!
\n
"
);
}
}
extern
"C"
{
void
c_hello
(
const
char
*
x
)
{
if
(
strlen
(
x
)
>
0
)
{
printf
(
"Hello, %s!
\n
"
,
x
);
}
else
{
printf
(
"Hello!
\n
"
);
}
}
}
\ No newline at end of file
tests/04_programs/basic6/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
<cstring>
extern
"C"
{
void
c_hello
(
const
char
*
x
)
{
if
(
strlen
(
x
)
>
0
)
printf
(
"Hello, %s!
\n
"
,
x
);
else
printf
(
"Hello!
\n
"
);
}
}
extern
"C"
{
void
c_hello
(
const
char
*
x
)
{
if
(
strlen
(
x
)
>
0
){
printf
(
"Hello, %s!
\n
"
,
x
);
}
else
{
printf
(
"Hello!
\n
"
);
}
}
}
\ No newline at end of file
tests/04_programs/basic7/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
<cstring>
extern
"C"
{
void
c_hello
(
const
char
*
x
)
{
if
(
strlen
(
x
)
>
0
)
printf
(
"Hello, %s!
\n
"
,
x
);
else
printf
(
"Hello!
\n
"
);
}
}
extern
"C"
{
void
c_hello
(
const
char
*
x
)
{
if
(
strlen
(
x
)
>
0
)
{
printf
(
"Hello, %s!
\n
"
,
x
);
}
else
{
printf
(
"Hello!
\n
"
);
}
}
}
\ No newline at end of file
tests/04_programs/complex1/ucodes.cpp
View file @
7b9aaf10
#include
<cstdio>
#include
"ucenv.h"
extern
"C"
{
extern
"C"