Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions oneapi-rs/examples/kernel_launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ async fn main() {
let mut device_buffer = queue.alloc_device::<f32>(1024).await;

let kernel = queue
.get_context()
.context()
.create_kernel_bundle_from_source(IOTA_SRC)
.build()
.get_kernel("iota");
.kernel("iota");

unsafe {
queue.launch(
Expand Down
4 changes: 2 additions & 2 deletions oneapi-rs/examples/kernel_launch_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ fn main() {
let mut buffer = queue.alloc_shared::<f32>(1024).wait();

let kernel = queue
.get_context()
.context()
.create_kernel_bundle_from_source(IOTA_SRC)
.build()
.get_kernel("iota");
.kernel("iota");

unsafe {
queue.launch(
Expand Down
14 changes: 7 additions & 7 deletions oneapi-rs/examples/sycl-ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
use oneapi_rs::prelude::*;

fn main() {
for platform in Platform::get_platforms() {
for device in platform.get_devices() {
let device_type = device.get_info::<info::device::DeviceType>();
let platform_name = platform.get_info::<info::platform::Name>();
let device_name = device.get_info::<info::device::Name>();
let device_version = device.get_info::<info::device::Version>();
let platform_version = platform.get_info::<info::platform::Version>();
for platform in Platform::all() {
for device in platform.devices() {
let device_type = device.info::<info::device::DeviceType>();
let platform_name = platform.info::<info::platform::Name>();
let device_name = device.info::<info::device::Name>();
let device_version = device.info::<info::device::Version>();
let platform_version = platform.info::<info::platform::Version>();

println!(
"[{device_type:?}] {platform_name}, {device_name} {device_version} [{platform_version}]"
Expand Down
4 changes: 2 additions & 2 deletions oneapi-rs/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ impl From<cxx::UniquePtr<ffi::Device>> for Device {
impl Device {
/// Returns a [`Vec`] containing all the root devices from all SYCL backends
/// available in the system which have the device type encapsulated by [`DeviceType`](crate::info::DeviceType).
pub fn get_devices() -> Vec<Self> {
pub fn all() -> Vec<Self> {
ffi::get_devices()
.into_iter()
.map(|device| Self(device.ptr))
.collect()
}

/// Returns the associated SYCL platform.
pub fn get_platform(&self) -> Platform {
pub fn platform(&self) -> Platform {
let raw_platform = ffi::get_platform(&self.0);
Platform(raw_platform)
}
Expand Down
6 changes: 3 additions & 3 deletions oneapi-rs/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ pub trait Info: Sealed {
type Target;

/// Returns information for a given Target.
fn get_item(target: &Self::Target) -> Self::Item;
fn item(target: &Self::Target) -> Self::Item;
}

/// Types which can be queried for information.
pub trait InfoTarget: Sealed {
/// Queries this object for information requested by given generic parameter.
fn get_info<T: Info<Target = Self>>(&self) -> T::Item {
T::get_item(self)
fn info<T: Info<Target = Self>>(&self) -> T::Item {
T::item(self)
}
}
6 changes: 3 additions & 3 deletions oneapi-rs/src/info/device-info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Sealed for DeviceType {}
impl Info for DeviceType {
type Item = crate::info::DeviceType;
type Target = Device;
fn get_item(target: &Self::Target) -> Self::Item {
fn item(target: &Self::Target) -> Self::Item {
ffi::get_device_type(&target.0)
}
}
Expand All @@ -28,7 +28,7 @@ impl Sealed for Version {}
impl Info for Version {
type Item = String;
type Target = Device;
fn get_item(target: &Self::Target) -> Self::Item {
fn item(target: &Self::Target) -> Self::Item {
ffi::get_version(&target.0)
}
}
Expand All @@ -39,7 +39,7 @@ impl Sealed for Name {}
impl Info for Name {
type Item = String;
type Target = Device;
fn get_item(target: &Self::Target) -> Self::Item {
fn item(target: &Self::Target) -> Self::Item {
ffi::get_name(&target.0)
}
}
2 changes: 1 addition & 1 deletion oneapi-rs/src/info/event-info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Sealed for CommandExecutionStatus {}
impl Info for CommandExecutionStatus {
type Item = crate::info::EventCommandStatus;
type Target = Event;
fn get_item(target: &Self::Target) -> Self::Item {
fn item(target: &Self::Target) -> Self::Item {
ffi::get_command_execution_status(&target.0)
}
}
6 changes: 3 additions & 3 deletions oneapi-rs/src/info/platform-info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Sealed for Version {}
impl Info for Version {
type Item = String;
type Target = Platform;
fn get_item(target: &Self::Target) -> Self::Item {
fn item(target: &Self::Target) -> Self::Item {
ffi::get_version(&target.0)
}
}
Expand All @@ -28,7 +28,7 @@ impl Sealed for Name {}
impl Info for Name {
type Item = String;
type Target = Platform;
fn get_item(target: &Self::Target) -> Self::Item {
fn item(target: &Self::Target) -> Self::Item {
ffi::get_name(&target.0)
}
}
Expand All @@ -39,7 +39,7 @@ impl Sealed for Vendor {}
impl Info for Vendor {
type Item = String;
type Target = Platform;
fn get_item(target: &Self::Target) -> Self::Item {
fn item(target: &Self::Target) -> Self::Item {
ffi::get_vendor(&target.0)
}
}
2 changes: 1 addition & 1 deletion oneapi-rs/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl From<cxx::UniquePtr<types::ffi::ExecutableKernelBundle>> for ExecutableKern
}

impl ExecutableKernelBundle {
pub fn get_kernel(&mut self, name: &str) -> Kernel {
pub fn kernel(&mut self, name: &str) -> Kernel {
ffi::get_kernel(&mut self.0, name).into()
}
}
Expand Down
4 changes: 2 additions & 2 deletions oneapi-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
//! 3. Build a SYCL kernel.
//! ```rust,ignore
//! let kernel = queue
//! .get_context()
//! .context()
//! .create_kernel_bundle_from_source(IOTA_SRC)
//! .build()
//! .get_kernel("iota");
//! .kernel("iota");
//! ```
//!
//! 4. Launch your kernel.
Expand Down
4 changes: 2 additions & 2 deletions oneapi-rs/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ impl InfoTarget for Platform {}

impl Platform {
/// Returns a [`Vec`] containing all SYCL platforms from all SYCL backends available in the system.
pub fn get_platforms() -> Vec<Self> {
pub fn all() -> Vec<Self> {
ffi::get_platforms()
.into_iter()
.map(|platform| Self(platform.ptr))
.collect()
}

/// Returns a [`Vec`] containing all the root devices associated with this `Platform`.
pub fn get_devices(&self) -> Vec<Device> {
pub fn devices(&self) -> Vec<Device> {
ffi::get_devices(&self.0)
.into_iter()
.map(|device| Device(device.ptr))
Expand Down
2 changes: 1 addition & 1 deletion oneapi-rs/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Queue {
}

/// Returns the SYCL queue’s context.
pub fn get_context(&self) -> Context {
pub fn context(&self) -> Context {
ffi::get_context(&self.0).into()
}

Expand Down