Skip to content

Commit

Permalink
bumped version to 0.5.2: bind through Device::set only (no guard)
Browse files Browse the repository at this point in the history
  • Loading branch information
gerwin3 committed Aug 15, 2023
1 parent 8c8070b commit 9f8c75b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ keywords = ["async", "nvidia", "cuda", "gpu", "tensorrt"]
readme = "README.md"
categories = ["asynchronous"]
edition = "2021"
version = "0.5.1"
version = "0.5.2"
authors = ["Oddity.ai Developers <hello@oddity.ai>"]
repository = "https://github.com/oddity-ai/async-tensorrt"
license = "MIT OR Apache-2.0"

[dependencies]
async-cuda = "0.5.3"
async-cuda = "0.5.4"
cpp = "0.5"
tracing = "0.1"

Expand Down
5 changes: 2 additions & 3 deletions src/ffi/sync/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ unsafe impl Sync for Builder {}

impl Builder {
pub fn new() -> Self {
let device =
Device::get().unwrap_or_else(|err| panic!("failed to get current device: {err}"));
let device = Device::get_or_panic();
let addr = cpp!(unsafe [] -> *mut std::ffi::c_void as "void*" {
return createInferBuilder(GLOBAL_LOGGER);
});
Expand Down Expand Up @@ -141,7 +140,7 @@ impl Builder {

impl Drop for Builder {
fn drop(&mut self) {
let _device_guard = Device::bind_or_panic(self.device);
Device::set_or_panic(self.device);
let internal = self.as_mut_ptr();
cpp!(unsafe [
internal as "void*"
Expand Down
6 changes: 3 additions & 3 deletions src/ffi/sync/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Engine {

impl Drop for Engine {
fn drop(&mut self) {
let _device_guard = Device::bind_or_panic(self.runtime.device());
Device::set_or_panic(self.runtime.device());
let Engine { internal, .. } = *self;
cpp!(unsafe [
internal as "void*"
Expand Down Expand Up @@ -262,7 +262,7 @@ impl<'engine> ExecutionContext<'engine> {
}

unsafe fn new_internal(engine: &mut Engine) -> *mut std::ffi::c_void {
let _device_guard = Device::bind_or_panic(engine.device());
Device::set_or_panic(engine.device());
let internal_engine = engine.as_mut_ptr();
let internal = cpp!(unsafe [
internal_engine as "void*"
Expand Down Expand Up @@ -301,7 +301,7 @@ impl<'engine> ExecutionContext<'engine> {

impl<'engine> Drop for ExecutionContext<'engine> {
fn drop(&mut self) {
let _device_guard = Device::bind_or_panic(self.device);
Device::set_or_panic(self.device);
let ExecutionContext { internal, .. } = *self;
cpp!(unsafe [
internal as "void*"
Expand Down
7 changes: 3 additions & 4 deletions src/ffi/sync/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ unsafe impl Sync for Runtime {}

impl Runtime {
pub fn new() -> Self {
let device =
Device::get().unwrap_or_else(|err| panic!("failed to get current device: {err}"));
let device = Device::get_or_panic();
let addr = cpp!(unsafe [] -> *mut std::ffi::c_void as "void*" {
return createInferRuntime(GLOBAL_LOGGER);
});
Expand Down Expand Up @@ -74,7 +73,7 @@ impl Runtime {
buffer_ptr: *const std::ffi::c_void,
buffer_size: usize,
) -> Result<Engine> {
Device::bind(self.device)?;
Device::set(self.device)?;
let internal = self.as_mut_ptr();
let internal_engine = cpp!(unsafe [
internal as "void*",
Expand Down Expand Up @@ -104,7 +103,7 @@ impl Runtime {

impl Drop for Runtime {
fn drop(&mut self) {
let _device_guard = Device::bind_or_panic(self.device);
Device::set_or_panic(self.device);
let internal = self.as_mut_ptr();
cpp!(unsafe [
internal as "void*"
Expand Down

0 comments on commit 9f8c75b

Please sign in to comment.