Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
Hercules
Commits
d29ce73b
Commit
d29ce73b
authored
6 months ago
by
Russel Arbore
Browse files
Options
Downloads
Patches
Plain Diff
Use cuda ptr functions for cuda device functions
parent
0640c58f
No related branches found
No related tags found
1 merge request
!104
Add CUDA support to HerculesBox
Pipeline
#200969
passed
6 months ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hercules_cg/src/rt.rs
+17
-7
17 additions, 7 deletions
hercules_cg/src/rt.rs
hercules_ir/src/ir.rs
+1
-1
1 addition, 1 deletion
hercules_ir/src/ir.rs
with
18 additions
and
8 deletions
hercules_cg/src/rt.rs
+
17
−
7
View file @
d29ce73b
...
...
@@ -295,10 +295,19 @@ impl<'a> RTContext<'a> {
ref
dynamic_constants
,
ref
args
,
}
=>
{
match
self
.devices
[
callee_id
.idx
()]
{
Device
::
LLVM
=>
{
let
device
=
self
.devices
[
callee_id
.idx
()];
match
device
{
// The device backends ensure that device functions have the
// same C interface.
Device
::
LLVM
|
Device
::
CUDA
=>
{
let
block
=
&
mut
blocks
.get_mut
(
&
self
.bbs
.0
[
id
.idx
()])
.unwrap
();
let
device
=
match
device
{
Device
::
LLVM
=>
"cpu"
,
Device
::
CUDA
=>
"cuda"
,
_
=>
panic!
(),
};
// First, get the raw pointers to collections that the
// device function takes as input.
let
callee_objs
=
&
self
.collection_objects
[
&
callee_id
];
...
...
@@ -308,16 +317,18 @@ impl<'a> RTContext<'a> {
if
callee_objs
.is_mutated
(
obj
)
{
write!
(
block
,
" let arg_tmp{} = unsafe {{ {}.__
cpu
_ptr_mut() }};
\n
"
,
" let arg_tmp{} = unsafe {{ {}.__
{}
_ptr_mut() }};
\n
"
,
idx
,
self
.get_value
(
*
arg
)
self
.get_value
(
*
arg
),
device
)
?
;
}
else
{
write!
(
block
,
" let arg_tmp{} = unsafe {{ {}.__
cpu
_ptr() }};
\n
"
,
" let arg_tmp{} = unsafe {{ {}.__
{}
_ptr() }};
\n
"
,
idx
,
self
.get_value
(
*
arg
)
self
.get_value
(
*
arg
),
device
)
?
;
}
}
else
{
...
...
@@ -401,7 +412,6 @@ impl<'a> RTContext<'a> {
}
write!
(
block
,
").await;
\n
"
)
?
;
}
_
=>
todo!
(),
}
}
_
=>
panic!
(
...
...
This diff is collapsed.
Click to expand it.
hercules_ir/src/ir.rs
+
1
−
1
View file @
d29ce73b
...
...
@@ -329,7 +329,7 @@ pub enum Schedule {
#[derive(Debug,
Clone,
Copy,
PartialEq,
Eq,
Serialize,
Deserialize)]
pub
enum
Device
{
LLVM
,
NVVM
,
CUDA
,
// Entry functions are lowered to async Rust code that calls device
// functions (leaf nodes in the call graph), possibly concurrently.
AsyncRust
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment