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
7e45a3c3
Commit
7e45a3c3
authored
3 months ago
by
prrathi
Browse files
Options
Downloads
Plain Diff
merged
parents
a4ded058
3b491c96
No related branches found
Branches containing commit
No related tags found
1 merge request
!115
GPU backend
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hercules_cg/src/rt.rs
+5
-4
5 additions, 4 deletions
hercules_cg/src/rt.rs
hercules_rt/src/lib.rs
+6
-1
6 additions, 1 deletion
hercules_rt/src/lib.rs
hercules_rt/src/rtdefs.cu
+4
-0
4 additions, 0 deletions
hercules_rt/src/rtdefs.cu
with
15 additions
and
5 deletions
hercules_cg/src/rt.rs
+
5
−
4
View file @
7e45a3c3
...
...
@@ -324,7 +324,7 @@ impl<'a> RTContext<'a> {
Node
::
Constant
{
id
:
cons_id
}
=>
{
let
block
=
&
mut
blocks
.get_mut
(
&
self
.bbs
.0
[
id
.idx
()])
.unwrap
();
write!
(
block
,
" {} = "
,
self
.get_value
(
id
))
?
;
let
mut
size
=
None
;
let
mut
size
_and_device
=
None
;
match
self
.module.constants
[
cons_id
.idx
()]
{
Constant
::
Boolean
(
val
)
=>
write!
(
block
,
"{}bool"
,
val
)
?
,
Constant
::
Integer8
(
val
)
=>
write!
(
block
,
"{}i8"
,
val
)
?
,
...
...
@@ -351,14 +351,15 @@ impl<'a> RTContext<'a> {
write!
(
block
,
"backing_{}.byte_add("
,
device
.name
())
?
;
self
.codegen_dynamic_constant
(
offset
,
block
)
?
;
write!
(
block
,
" as usize)"
)
?
;
size
=
Some
(
self
.codegen_type_size
(
ty
));
size
_and_device
=
Some
(
(
self
.codegen_type_size
(
ty
)
,
device
)
);
}
}
write!
(
block
,
";
\n
"
)
?
;
if
let
Some
(
size
)
=
siz
e
{
if
let
Some
(
(
size
,
device
))
=
size_and_devic
e
{
write!
(
block
,
" ::core::ptr::write_bytes({}, 0, {} as usize);
\n
"
,
" ::hercules_rt::__{}_zero_mem({}, {} as usize);
\n
"
,
device
.name
(),
self
.get_value
(
id
),
size
)
?
;
...
...
This diff is collapsed.
Click to expand it.
hercules_rt/src/lib.rs
+
6
−
1
View file @
7e45a3c3
use
std
::
alloc
::{
alloc
,
dealloc
,
Layout
};
use
std
::
marker
::
PhantomData
;
use
std
::
ptr
::{
copy_nonoverlapping
,
NonNull
};
use
std
::
ptr
::{
copy_nonoverlapping
,
write_bytes
,
NonNull
};
use
std
::
slice
::{
from_raw_parts
,
from_raw_parts_mut
};
/*
...
...
@@ -17,6 +17,10 @@ pub unsafe fn __cpu_dealloc(ptr: *mut u8, size: usize) {
dealloc
(
ptr
,
Layout
::
from_size_align
(
size
,
16
)
.unwrap
())
}
pub
unsafe
fn
__cpu_zero_mem
(
ptr
:
*
mut
u8
,
size
:
usize
)
{
write_bytes
(
ptr
,
0
,
size
);
}
pub
unsafe
fn
__copy_cpu_to_cpu
(
dst
:
*
mut
u8
,
src
:
*
mut
u8
,
size
:
usize
)
{
copy_nonoverlapping
(
src
,
dst
,
size
);
}
...
...
@@ -25,6 +29,7 @@ pub unsafe fn __copy_cpu_to_cpu(dst: *mut u8, src: *mut u8, size: usize) {
extern
"C"
{
pub
fn
__cuda_alloc
(
size
:
usize
)
->
*
mut
u8
;
pub
fn
__cuda_dealloc
(
ptr
:
*
mut
u8
,
size
:
usize
);
pub
fn
__cuda_zero_mem
(
ptr
:
*
mut
u8
,
size
:
usize
);
pub
fn
__copy_cpu_to_cuda
(
dst
:
*
mut
u8
,
src
:
*
mut
u8
,
size
:
usize
);
pub
fn
__copy_cuda_to_cpu
(
dst
:
*
mut
u8
,
src
:
*
mut
u8
,
size
:
usize
);
pub
fn
__copy_cuda_to_cuda
(
dst
:
*
mut
u8
,
src
:
*
mut
u8
,
size
:
usize
);
...
...
This diff is collapsed.
Click to expand it.
hercules_rt/src/rtdefs.cu
+
4
−
0
View file @
7e45a3c3
...
...
@@ -13,6 +13,10 @@ extern "C" {
cudaFree
(
ptr
);
}
void
__cuda_zero_mem
(
void
*
ptr
,
size_t
size
)
{
cudaMemset
(
ptr
,
0
,
size
);
}
void
__copy_cpu_to_cuda
(
void
*
dst
,
void
*
src
,
size_t
size
)
{
cudaMemcpy
(
dst
,
src
,
size
,
cudaMemcpyHostToDevice
);
}
...
...
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