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
16bdbabd
Commit
16bdbabd
authored
1 month ago
by
Russel Arbore
Browse files
Options
Downloads
Patches
Plain Diff
bruh
parent
fd863925
No related branches found
No related tags found
1 merge request
!190
Set up cava benchmark
Pipeline
#201770
passed
1 month ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hercules_rt/src/lib.rs
+2
-7
2 additions, 7 deletions
hercules_rt/src/lib.rs
with
2 additions
and
7 deletions
hercules_rt/src/lib.rs
+
2
−
7
View file @
16bdbabd
#![feature(once_cell_try
,
pointer_is_aligned_to
)]
#![feature(once_cell_try)]
use
std
::
alloc
::{
alloc
,
dealloc
,
GlobalAlloc
,
Layout
,
System
};
use
std
::
alloc
::{
alloc
,
dealloc
,
GlobalAlloc
,
Layout
,
System
};
use
std
::
marker
::
PhantomData
;
use
std
::
marker
::
PhantomData
;
...
@@ -189,7 +189,6 @@ pub struct CUDABox {
...
@@ -189,7 +189,6 @@ pub struct CUDABox {
impl
<
'a
>
HerculesCPURef
<
'a
>
{
impl
<
'a
>
HerculesCPURef
<
'a
>
{
pub
fn
from_slice
<
T
>
(
slice
:
&
'a
[
T
])
->
Self
{
pub
fn
from_slice
<
T
>
(
slice
:
&
'a
[
T
])
->
Self
{
assert!
(
slice
.as_ptr
()
.is_aligned_to
(
LARGEST_ALIGNMENT
));
let
ptr
=
unsafe
{
NonNull
::
new_unchecked
(
slice
.as_ptr
()
as
*
mut
u8
)
};
let
ptr
=
unsafe
{
NonNull
::
new_unchecked
(
slice
.as_ptr
()
as
*
mut
u8
)
};
let
size
=
slice
.len
()
*
size_of
::
<
T
>
();
let
size
=
slice
.len
()
*
size_of
::
<
T
>
();
Self
{
Self
{
...
@@ -202,6 +201,7 @@ impl<'a> HerculesCPURef<'a> {
...
@@ -202,6 +201,7 @@ impl<'a> HerculesCPURef<'a> {
pub
fn
as_slice
<
T
>
(
self
)
->
&
'a
[
T
]
{
pub
fn
as_slice
<
T
>
(
self
)
->
&
'a
[
T
]
{
let
ptr
=
self
.ptr
.as_ptr
()
as
*
const
T
;
let
ptr
=
self
.ptr
.as_ptr
()
as
*
const
T
;
assert_eq!
(
self
.size
%
size_of
::
<
T
>
(),
0
);
assert_eq!
(
self
.size
%
size_of
::
<
T
>
(),
0
);
assert!
(
ptr
.is_aligned
());
unsafe
{
from_raw_parts
(
ptr
,
self
.size
/
size_of
::
<
T
>
())
}
unsafe
{
from_raw_parts
(
ptr
,
self
.size
/
size_of
::
<
T
>
())
}
}
}
...
@@ -214,7 +214,6 @@ impl<'a> HerculesCPURef<'a> {
...
@@ -214,7 +214,6 @@ impl<'a> HerculesCPURef<'a> {
}
}
pub
unsafe
fn
__from_parts
(
ptr
:
*
mut
u8
,
size
:
usize
)
->
Self
{
pub
unsafe
fn
__from_parts
(
ptr
:
*
mut
u8
,
size
:
usize
)
->
Self
{
assert!
(
ptr
.is_aligned_to
(
LARGEST_ALIGNMENT
));
Self
{
Self
{
ptr
:
NonNull
::
new
(
ptr
)
.unwrap
(),
ptr
:
NonNull
::
new
(
ptr
)
.unwrap
(),
size
,
size
,
...
@@ -225,7 +224,6 @@ impl<'a> HerculesCPURef<'a> {
...
@@ -225,7 +224,6 @@ impl<'a> HerculesCPURef<'a> {
impl
<
'a
>
HerculesCPURefMut
<
'a
>
{
impl
<
'a
>
HerculesCPURefMut
<
'a
>
{
pub
fn
from_slice
<
T
>
(
slice
:
&
'a
mut
[
T
])
->
Self
{
pub
fn
from_slice
<
T
>
(
slice
:
&
'a
mut
[
T
])
->
Self
{
assert!
(
slice
.as_ptr
()
.is_aligned_to
(
LARGEST_ALIGNMENT
));
let
ptr
=
unsafe
{
NonNull
::
new_unchecked
(
slice
.as_ptr
()
as
*
mut
u8
)
};
let
ptr
=
unsafe
{
NonNull
::
new_unchecked
(
slice
.as_ptr
()
as
*
mut
u8
)
};
let
size
=
slice
.len
()
*
size_of
::
<
T
>
();
let
size
=
slice
.len
()
*
size_of
::
<
T
>
();
Self
{
Self
{
...
@@ -259,7 +257,6 @@ impl<'a> HerculesCPURefMut<'a> {
...
@@ -259,7 +257,6 @@ impl<'a> HerculesCPURefMut<'a> {
}
}
pub
unsafe
fn
__from_parts
(
ptr
:
*
mut
u8
,
size
:
usize
)
->
Self
{
pub
unsafe
fn
__from_parts
(
ptr
:
*
mut
u8
,
size
:
usize
)
->
Self
{
assert!
(
ptr
.is_aligned_to
(
LARGEST_ALIGNMENT
));
Self
{
Self
{
ptr
:
NonNull
::
new
(
ptr
)
.unwrap
(),
ptr
:
NonNull
::
new
(
ptr
)
.unwrap
(),
size
,
size
,
...
@@ -271,7 +268,6 @@ impl<'a> HerculesCPURefMut<'a> {
...
@@ -271,7 +268,6 @@ impl<'a> HerculesCPURefMut<'a> {
#[cfg(feature
=
"cuda"
)]
#[cfg(feature
=
"cuda"
)]
impl
<
'a
>
HerculesCUDARef
<
'a
>
{
impl
<
'a
>
HerculesCUDARef
<
'a
>
{
pub
fn
to_cpu_ref
<
'b
,
T
>
(
self
,
dst
:
&
'b
mut
[
T
])
->
HerculesCPURefMut
<
'b
>
{
pub
fn
to_cpu_ref
<
'b
,
T
>
(
self
,
dst
:
&
'b
mut
[
T
])
->
HerculesCPURefMut
<
'b
>
{
assert!
(
dst
.as_ptr
()
.is_aligned_to
(
LARGEST_ALIGNMENT
));
unsafe
{
unsafe
{
let
size
=
self
.size
;
let
size
=
self
.size
;
assert_eq!
(
size
,
dst
.len
()
*
size_of
::
<
T
>
());
assert_eq!
(
size
,
dst
.len
()
*
size_of
::
<
T
>
());
...
@@ -313,7 +309,6 @@ impl<'a> HerculesCUDARefMut<'a> {
...
@@ -313,7 +309,6 @@ impl<'a> HerculesCUDARefMut<'a> {
}
}
pub
fn
to_cpu_ref
<
'b
,
T
>
(
self
,
dst
:
&
mut
[
T
])
->
HerculesCPURefMut
<
'b
>
{
pub
fn
to_cpu_ref
<
'b
,
T
>
(
self
,
dst
:
&
mut
[
T
])
->
HerculesCPURefMut
<
'b
>
{
assert!
(
dst
.as_ptr
()
.is_aligned_to
(
LARGEST_ALIGNMENT
));
unsafe
{
unsafe
{
let
size
=
self
.size
;
let
size
=
self
.size
;
let
ptr
=
NonNull
::
new
(
dst
.as_ptr
()
as
*
mut
u8
)
.unwrap
();
let
ptr
=
NonNull
::
new
(
dst
.as_ptr
()
as
*
mut
u8
)
.unwrap
();
...
...
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