-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes 49. hipextmallocwithflags (#107)
* memory methods on struct. Add malloc_with_flags()
- Loading branch information
1 parent
f57d39e
commit c6f8cc3
Showing
6 changed files
with
111 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
use super::sys; | ||
use crate::types::{Device, MemoryPointer, Result}; | ||
|
||
/// Allocates memory on a HIP device/accelerator. | ||
/// | ||
/// This function allocates a block of `size` bytes of device memory and returns a | ||
/// MemoryPointer that safely manages the memory allocation. The memory will be | ||
/// automatically freed when the MemoryPointer is dropped. | ||
/// | ||
/// If 0 is passed for `size`, `Ok(std::ptr::null_mut)` is returned. | ||
/// | ||
/// # Arguments | ||
/// * `size` - Size of memory allocation in bytes | ||
/// | ||
/// # Returns | ||
/// * `Ok(MemoryPointer)` - Handle to allocated device memory | ||
/// * `Err(HipError)` - Error occurred during allocation | ||
/// ``` | ||
pub fn malloc<T>(size: usize) -> Result<MemoryPointer<T>> { | ||
MemoryPointer::new(size) | ||
} | ||
use crate::DeviceMallocFlag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use bitflags::bitflags; | ||
|
||
bitflags::bitflags! { | ||
pub struct DeviceMallocFlag: u32 { | ||
const DEFAULT = 0x0; | ||
const FINEGRAINED = 0x1; | ||
const SIGNAL_MEMORY = 0x2; | ||
const UNCACHED = 0x3; | ||
const CONTIGUOUS = 0x4; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
mod device; | ||
mod flags; | ||
mod memory; | ||
mod result; | ||
|
||
pub use device::*; | ||
pub use flags::*; | ||
pub use memory::*; | ||
pub use result::*; |