Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
8b756c8b
Commit
8b756c8b
authored
Aug 23, 2023
by
Paul
Browse files
Fix bugs with work stealing
parent
58924228
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
src/targets/gpu/compile_ops.cpp
src/targets/gpu/compile_ops.cpp
+8
-8
No files found.
src/targets/gpu/compile_ops.cpp
View file @
8b756c8b
...
@@ -212,11 +212,15 @@ struct parallel_work
...
@@ -212,11 +212,15 @@ struct parallel_work
std
::
size_t
stop
=
0
;
std
::
size_t
stop
=
0
;
std
::
shared_ptr
<
std
::
mutex
>
m
=
std
::
make_shared
<
std
::
mutex
>
();
std
::
shared_ptr
<
std
::
mutex
>
m
=
std
::
make_shared
<
std
::
mutex
>
();
// parallel_work(parallel_work&&) noexcept = default;
bool
empty
()
const
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
*
m
);
return
start
>=
stop
;
}
optional
<
std
::
size_t
>
pop
()
optional
<
std
::
size_t
>
pop
()
{
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
*
m
);
std
::
lock_guard
<
std
::
mutex
>
guard
(
*
m
);
if
(
st
op
>=
st
art
)
if
(
st
art
>=
st
op
)
return
nullopt
;
return
nullopt
;
return
start
++
;
return
start
++
;
}
}
...
@@ -228,13 +232,12 @@ void par_compile(std::size_t n, F f)
...
@@ -228,13 +232,12 @@ void par_compile(std::size_t n, F f)
if
(
n
==
0
)
if
(
n
==
0
)
return
;
return
;
std
::
cout
<<
"Compile: "
<<
n
<<
std
::
endl
;
std
::
cout
<<
"Compile: "
<<
n
<<
std
::
endl
;
auto
d
=
value_of
(
MIGRAPHX_GPU_COMPILE_PARALLEL
{},
std
::
thread
::
hardware_concurrency
());
auto
d
=
std
::
min
(
n
,
value_of
(
MIGRAPHX_GPU_COMPILE_PARALLEL
{},
std
::
thread
::
hardware_concurrency
())
)
;
std
::
size_t
grainsize
=
std
::
ceil
(
static_cast
<
double
>
(
n
)
/
d
);
std
::
size_t
grainsize
=
std
::
ceil
(
static_cast
<
double
>
(
n
)
/
d
);
std
::
vector
<
parallel_work
>
pw
(
d
);
std
::
vector
<
parallel_work
>
pw
(
d
);
std
::
size_t
work
=
0
;
std
::
size_t
work
=
0
;
std
::
generate
(
pw
.
begin
(),
pw
.
end
(),
[
&
]
{
std
::
generate
(
pw
.
begin
(),
pw
.
end
(),
[
&
]
{
std
::
cout
<<
"Work: "
<<
work
<<
", "
<<
(
work
+
grainsize
)
<<
std
::
endl
;
parallel_work
p
{
work
,
std
::
min
(
n
,
work
+
grainsize
)};
parallel_work
p
{
work
,
work
+
grainsize
};
work
+=
grainsize
;
work
+=
grainsize
;
return
p
;
return
p
;
});
});
...
@@ -249,10 +252,7 @@ void par_compile(std::size_t n, F f)
...
@@ -249,10 +252,7 @@ void par_compile(std::size_t n, F f)
return
false
;
return
false
;
auto
w
=
pw
[
k
].
pop
();
auto
w
=
pw
[
k
].
pop
();
if
(
w
.
has_value
())
if
(
w
.
has_value
())
{
std
::
cout
<<
"Steal"
<<
std
::
endl
;
f
(
*
w
);
f
(
*
w
);
}
return
w
.
has_value
();
return
w
.
has_value
();
}))
}))
;
;
...
...
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