diff --git a/CHANGELOG.md b/CHANGELOG.md index db9ef50..6b10dd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.1.1] - 2022-07-10 +There are no update steps from the previous version. +### Added +- Nothing +### Changed +- The crate is now `#![no_std]` +### Fixed +- Nothing + +--- + ## [1.1.0] - 2022-05-30 There are no update steps from the previous version. ### Added diff --git a/Cargo.toml b/Cargo.toml index a78c1ef..7e3078d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "nvtx" -version = "1.1.0" +version = "1.1.1" authors = ["Spencer Imbleau "] edition = "2021" description = "Rust bindings for the NVIDIA® Tools Extension SDK (NVTX)" repository = "https://github.com/simbleau/nvtx" license = "MIT OR Apache-2.0" -categories = ["api-bindings"] +categories = ["api-bindings", "no-std"] readme = "README.md" include = ["nvtx-sys/NVTX/c/*", "nvtx-sys/export.c", "src/*", "build.rs"] diff --git a/README.md b/README.md index ac01950..557e8bf 100644 --- a/README.md +++ b/README.md @@ -6,32 +6,32 @@ [![Build Status](https://github.com/simbleau/nvtx/workflows/build/badge.svg)](https://github.com/simbleau/nvtx/actions/workflows/build.yml) [![dependency status](https://deps.rs/repo/github/simbleau/nvtx/status.svg)](https://deps.rs/repo/github/simbleau/nvtx) -A safe rust wrapper for the NVIDIA® Tools Extension SDK (NVTX) with zero-cost abstraction. +A safe and ergonomic `#![no_std]` crate to bind the NVIDIA® Tools Extension SDK (NVTX) with zero-cost abstraction. NVIDIA® Tools Extension SDK (NVTX) is a C-based Application Programming Interface (API) for annotating events, code ranges, and resources in your applications. Official documentation for NVIDIA®'s NVTX can be found [here](https://nvidia.github.io/NVTX/doxygen/index.html). -This library is a wrapper over that SDK, safely, and with zero-cost abstractions. This library facilitates integration into the rich CPU and GPU profiling tools provided by NVIDIA®, such as NSight Systems. The primary motivation for this library is to assist research GPU analysts and bring NVIDIA® tools to Rust. +This library is a wrapper over that SDK, safely, and with zero-cost abstractions. This library facilitates integration into the rich CPU and GPU profiling tools provided by NVIDIA®, such as NSight Systems. The primary motivation for this library is to assist research GPU analysts and bring NVIDIA® tools to Rust. This crate is `#![no_std]`. # ➡️ Quickstart The crate is published on [crates.io](https://crates.io/crates/nvtx) and the easiest way to use nvtx is by adding the dependency to your `Cargo.toml` file: ```toml -nvtx = "1.1.0" +nvtx = "1.1.1" ``` -![Hello, World](examples/hello_world/screenshot.png) +![Example](assets/screenshot.png) There are several examples in the [`examples`](examples) folder which can be executed through tools such as NSight Systems. Each example has a README document with easy to read steps, screenshots, and documentation. Check out the first example, '[Hello, World!](https://github.com/simbleau/nvtx/tree/main/examples/hello_world)' -Don't hesitate to [file an issue](https://github.com/simbleau/nvtx/issues/new) if you need help. +🙋 *If you need support, please [file an issue](https://github.com/simbleau/nvtx/issues/new) or [start a discussion](https://github.com/simbleau/nvtx/discussions/new).* --- ## 🤝 Contributing -If you support the project, consider [sponsoring](https://github.com/sponsors/simbleau) or [buying a coffee](https://www.buymeacoffee.com/simbleau). Otherwise, I encourage all contributions by pull request. Please check the [issues](https://github.com/simbleau/nvtx/issues) if you'd like to help. Another great place to start would be binding more functions and wrapping them in a safe way. +If you support the project, consider [sponsoring](https://github.com/sponsors/simbleau) or [buying a coffee](https://www.buymeacoffee.com/simbleau). Otherwise, any help is welcome, including pull requests. Please check the [active issues](https://github.com/simbleau/nvtx/issues) if you'd like to help. The [Rust code of conduct](https://www.rust-lang.org/policies/code-of-conduct) applies. diff --git a/assets/screenshot.png b/assets/screenshot.png new file mode 100644 index 0000000..b91a029 Binary files /dev/null and b/assets/screenshot.png differ diff --git a/src/bindings.rs b/src/bindings.rs index 2c4915a..39f1bd1 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -1,13 +1,14 @@ -use std::ffi::CString; -use std::fmt::Display; +extern crate alloc; +use alloc::{ffi::CString, string::ToString}; +use core::fmt::Display; #[doc(hidden)] pub fn _range_push(message: M) -> i32 { #[link(name = "nvtx")] extern "C" { fn ffi_range_push( - message: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int; + message: *const ::core::ffi::c_char, + ) -> ::core::ffi::c_int; } let message: CString = CString::new(message.to_string()).expect("Invalid thread range name"); @@ -19,7 +20,7 @@ pub fn _range_push(message: M) -> i32 { pub fn _range_pop() -> i32 { #[link(name = "nvtx")] extern "C" { - fn ffi_range_pop() -> ::std::os::raw::c_int; + fn ffi_range_pop() -> ::core::ffi::c_int; } // SAFETY: If the function signature matches nvtx-sys/export.rs unsafe { ffi_range_pop() } @@ -29,7 +30,7 @@ pub fn _range_pop() -> i32 { pub fn _mark(message: M) { #[link(name = "nvtx")] extern "C" { - fn ffi_mark(message: *const ::std::os::raw::c_char); + fn ffi_mark(message: *const ::core::ffi::c_char); } let message: CString = CString::new(message.to_string()).expect("Invalid marker name"); @@ -41,7 +42,7 @@ pub fn _mark(message: M) { pub fn _name_thread(name: M) { #[link(name = "nvtx")] extern "C" { - fn ffi_name_thread(name: *const ::std::os::raw::c_char); + fn ffi_name_thread(name: *const ::core::ffi::c_char); } let name: CString = CString::new(name.to_string()).expect("Invalid thread name"); diff --git a/src/lib.rs b/src/lib.rs index cdacb1f..4644553 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,13 @@ +// This crate does not use the standard library +#![no_std] +#![feature(core_ffi_c)] +#![feature(alloc_c_string)] // Enforce stricter documentation requirements #![warn(missing_docs)] #![warn(rustdoc::missing_crate_level_docs)] #![warn(rustdoc::missing_doc_code_examples)] #![warn(rustdoc::invalid_codeblock_attributes)] #![warn(rustdoc::broken_intra_doc_links)] -#![feature(thread_id_value)] //! A safe rust FFI binding for the NVIDIA® Tools Extension SDK (NVTX).
//! NVTX API doxygen documentation by NVIDIA® can be found [here](https://nvidia.github.io/NVTX/doxygen/index.html).