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
ef048a56
Commit
ef048a56
authored
Aug 16, 2018
by
Paul
Browse files
Formatting
parent
84242aae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
src/targets/gpu/hip.cpp
src/targets/gpu/hip.cpp
+5
-4
src/targets/gpu/include/migraph/gpu/hip.hpp
src/targets/gpu/include/migraph/gpu/hip.hpp
+2
-2
No files found.
src/targets/gpu/hip.cpp
View file @
ef048a56
...
@@ -22,14 +22,15 @@ std::size_t get_available_gpu_memory()
...
@@ -22,14 +22,15 @@ std::size_t get_available_gpu_memory()
return
free
;
return
free
;
}
}
hip_ptr
allocate_gpu
(
std
::
size_t
sz
,
bool
host
=
false
)
hip_ptr
allocate_gpu
(
std
::
size_t
sz
,
bool
host
=
false
)
{
{
if
(
sz
>
get_available_gpu_memory
())
if
(
sz
>
get_available_gpu_memory
())
MIGRAPH_THROW
(
"Memory not available to allocate buffer: "
+
std
::
to_string
(
sz
));
MIGRAPH_THROW
(
"Memory not available to allocate buffer: "
+
std
::
to_string
(
sz
));
void
*
result
;
void
*
result
;
auto
status
=
host
?
hipHostMalloc
(
&
result
,
sz
)
:
hipMalloc
(
&
result
,
sz
);
auto
status
=
host
?
hipHostMalloc
(
&
result
,
sz
)
:
hipMalloc
(
&
result
,
sz
);
if
(
status
!=
hipSuccess
)
{
if
(
status
!=
hipSuccess
)
if
(
host
)
{
if
(
host
)
MIGRAPH_THROW
(
"Gpu allocation failed: "
+
hip_error
(
status
));
MIGRAPH_THROW
(
"Gpu allocation failed: "
+
hip_error
(
status
));
else
else
allocate_gpu
(
sz
,
true
);
allocate_gpu
(
sz
,
true
);
...
@@ -55,7 +56,7 @@ std::vector<T> read_from_gpu(const void* x, std::size_t sz)
...
@@ -55,7 +56,7 @@ std::vector<T> read_from_gpu(const void* x, std::size_t sz)
return
result
;
return
result
;
}
}
hip_ptr
write_to_gpu
(
const
void
*
x
,
std
::
size_t
sz
,
bool
host
=
false
)
hip_ptr
write_to_gpu
(
const
void
*
x
,
std
::
size_t
sz
,
bool
host
=
false
)
{
{
auto
result
=
allocate_gpu
(
sz
,
host
);
auto
result
=
allocate_gpu
(
sz
,
host
);
auto
status
=
hipMemcpy
(
result
.
get
(),
x
,
sz
,
hipMemcpyHostToDevice
);
auto
status
=
hipMemcpy
(
result
.
get
(),
x
,
sz
,
hipMemcpyHostToDevice
);
...
...
src/targets/gpu/include/migraph/gpu/hip.hpp
View file @
ef048a56
...
@@ -6,9 +6,9 @@
...
@@ -6,9 +6,9 @@
namespace
migraph
{
namespace
migraph
{
namespace
gpu
{
namespace
gpu
{
migraph
::
argument
allocate_gpu
(
migraph
::
shape
s
,
bool
host
=
false
);
migraph
::
argument
allocate_gpu
(
migraph
::
shape
s
,
bool
host
=
false
);
migraph
::
argument
to_gpu
(
migraph
::
argument
arg
,
bool
host
=
false
);
migraph
::
argument
to_gpu
(
migraph
::
argument
arg
,
bool
host
=
false
);
migraph
::
argument
from_gpu
(
migraph
::
argument
arg
);
migraph
::
argument
from_gpu
(
migraph
::
argument
arg
);
...
...
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