Skip to content

Commit

Permalink
Merge pull request #11 from simbleau/10-make-crate-no-std
Browse files Browse the repository at this point in the history
Crate is now #![no_std]
  • Loading branch information
simbleau committed Jul 10, 2022
2 parents b0139c0 + 300ae54 commit 5a5e434
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "nvtx"
version = "1.1.0"
version = "1.1.1"
authors = ["Spencer Imbleau <spencer@imbleau.com>"]
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"]

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Binary file added assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions src/bindings.rs
Original file line number Diff line number Diff line change
@@ -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<M: Display>(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");
Expand All @@ -19,7 +20,7 @@ pub fn _range_push<M: Display>(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() }
Expand All @@ -29,7 +30,7 @@ pub fn _range_pop() -> i32 {
pub fn _mark<M: Display>(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");
Expand All @@ -41,7 +42,7 @@ pub fn _mark<M: Display>(message: M) {
pub fn _name_thread<M: Display>(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");
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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). </br>
//! NVTX API doxygen documentation by NVIDIA® can be found [here](https://nvidia.github.io/NVTX/doxygen/index.html).
Expand Down

0 comments on commit 5a5e434

Please sign in to comment.