Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dubský Jan
asgn
Commits
c45d09cf
Commit
c45d09cf
authored
May 19, 2020
by
Dubský Jan
Browse files
Solution 4.03.2 (Speed: 1.56)
parent
53ec8c75
Changes
1
Hide whitespace changes
Inline
Side-by-side
sol/matrixsol.hpp
View file @
c45d09cf
...
...
@@ -20,8 +20,8 @@ public:
matrix_base
(
std
::
size_t
vs
,
std
::
size_t
hs
,
size_t
vec_size
)
:
VS
(
vs
),
HS
(
hs
),
VEC_SIZE
(
vec_size
),
VEC_CNT
(
VEC_SIZE
/
sizeof
(
matrix_element
)),
ROW_BYTES
(
calc_row_bytes
(
hs
)),
COL_BYTES
(
calc_row_bytes
(
vs
)),
ROW_SIZE
(
ROW_BYTES
/
sizeof
(
matrix_element
)),
COL_SIZE
(
COL_BYTES
/
sizeof
(
matrix_element
))
{
mat
=
(
uint16_
t
*
)
std
::
aligned_alloc
(
CACHE_LINE_SIZE
,
VS
*
ROW_BYTES
);
aggr_arr
=
(
uint16_
t
*
)
std
::
aligned_alloc
(
CACHE_LINE_SIZE
,
VEC_SIZE
);
mat
=
(
matrix_elemen
t
*
)
std
::
aligned_alloc
(
CACHE_LINE_SIZE
,
VS
*
ROW_BYTES
);
aggr_arr
=
(
matrix_elemen
t
*
)
std
::
aligned_alloc
(
CACHE_LINE_SIZE
,
VEC_SIZE
);
assert
(((
size_t
)(
mat
)
&
(
CACHE_LINE_SIZE
-
1
))
==
0
);
assert
(((
size_t
)(
aggr_arr
)
&
(
CACHE_LINE_SIZE
-
1
))
==
0
);
...
...
@@ -48,8 +48,8 @@ protected:
const
size_t
VEC_SIZE
,
VEC_CNT
;
const
size_t
ROW_BYTES
,
COL_BYTES
;
const
size_t
ROW_SIZE
,
COL_SIZE
;
uint16_
t
*
mat
;
uint16_
t
*
aggr_arr
;
matrix_elemen
t
*
mat
;
matrix_elemen
t
*
aggr_arr
;
matrix_element
&
addr
(
size_t
row
,
size_t
col
)
const
{
assert
(
col
<
HS
);
...
...
@@ -80,8 +80,14 @@ public:
assert
(
a
.
HS
==
b
.
VS
);
for
(
size_t
j
=
0
;
j
<
HS
;
++
j
)
{
matrix_element
b_copy
[
a
.
HS
];
for
(
size_t
i
=
0
;
i
<
a
.
HS
;
++
i
)
b_copy
[
i
]
=
b
.
addr
(
i
,
j
);
// This is useless - compiles vectorizes normal loop here
const
size_t
B_COPY_SIZE
=
(
a
.
HS
+
VEC_CNT
-
1
)
/
VEC_CNT
*
VEC_CNT
;
matrix_element
b_copy
[
B_COPY_SIZE
];
for
(
size_t
i
=
0
;
i
<
B_COPY_SIZE
/
VEC_CNT
;
++
i
)
{
const
size_t
k
=
i
*
VEC_CNT
;
__m128i
vec
=
_mm_setr_epi16
(
b
.
addr
(
k
+
0
,
j
),
b
.
addr
(
k
+
1
,
j
),
b
.
addr
(
k
+
2
,
j
),
b
.
addr
(
k
+
3
,
j
),
b
.
addr
(
k
+
4
,
j
),
b
.
addr
(
k
+
5
,
j
),
b
.
addr
(
k
+
6
,
j
),
b
.
addr
(
k
+
7
,
j
));
_mm_storeu_si128
((
__m128i
*
)
&
b_copy
[
i
*
VEC_CNT
],
vec
);
}
for
(
size_t
i
=
0
;
i
<
VS
;
++
i
)
{
const
matrix_element
res_init_val
=
std
::
numeric_limits
<
matrix_element
>::
max
();
...
...
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