docs: improving readme, removing unused function from build.rs
This commit is contained in:
+2
-2
@@ -4,7 +4,7 @@ version = "0.4.2"
|
||||
edition = "2024"
|
||||
description = "Rust bindings for AMD ROCm libraries"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/radudiaconu0/rocm-rs"
|
||||
repository = "https://github.com/RustNSparks/rocm-rs"
|
||||
documentation = "https://docs.rs/rocm-rs"
|
||||
readme = "README.md"
|
||||
keywords = ["gpu", "rocm", "amd", "hpc", "bindings"]
|
||||
@@ -20,7 +20,7 @@ once_cell = "1.21.3"
|
||||
bindgen = "0.71.1"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["macros"]
|
||||
rocm_smi = ["dep:rocm_smi_lib"]
|
||||
miopen = []
|
||||
rocprofiler = []
|
||||
|
||||
@@ -14,7 +14,7 @@ Currently implemented:
|
||||
- ✅ rocRAND - Random number generation (raw bindings + safe wrappers)
|
||||
- ✅ rocSOLVER - Linear system solvers (raw bindings only)
|
||||
- ✅ rocSPARSE - Sparse linear algebra (raw bindings only)
|
||||
- ✅ ROCArray - GPU array struct with api similar to Vec
|
||||
- ✅ ROCArray - GPU array struct with api similar to Vec (to be deprecated in favor of DeviceMemoryExt)
|
||||
- ✅ rocmsmi - system managment interface (refer to [rocm_smi_lib](https://github.com/PTFOPlayer/rocm_smi_lib_rs))
|
||||
- ✅ rocm_kernel_macros - macros for writing gpu kernels in rust(refer to [rocm_kernel_macros](https://github.com/RustNSparks/rocm_kernel_macros))
|
||||
|
||||
@@ -23,7 +23,7 @@ The project currently focuses on providing raw FFI bindings for most libraries,
|
||||
## Prerequisites
|
||||
|
||||
- AMD ROCm installed (version 6.3 or later recommended.It may work on older versions, but I did not test that)
|
||||
- Ubuntu 24.04 (it works on WSL too)
|
||||
- Ubuntu 24.04 / Fedora 42
|
||||
- Rust toolchain (1.65.0 or later recommended)
|
||||
- A compatible AMD GPU
|
||||
|
||||
@@ -33,7 +33,7 @@ Add this to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
rocm-rs = "0.1.0"
|
||||
rocm-rs = "4.2"
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -159,7 +159,7 @@ fn main() {
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/radudiaconu0/rocm-rs.git
|
||||
git clone https://github.com/RustNSparks/rocm-rs
|
||||
cd rocm-rs
|
||||
|
||||
# Set the ROCm path if not in the default location
|
||||
@@ -178,6 +178,7 @@ cargo build
|
||||
- vector_add - example containing kernel written in cpp launched with rocm-rs
|
||||
- rust_kernel - example containing kernel written in in rust using macros
|
||||
- rust_kernel_async - example containing kernel written in in rust, using stream to manage memory asynchronously
|
||||
- saxpy - X = aX+Y
|
||||
- rand
|
||||
- normal - generating random numbers with normal distribution
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::collections::HashSet;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use bindgen::CargoCallbacks;
|
||||
|
||||
|
||||
// Define module configuration with enhanced options
|
||||
struct ModuleConfig {
|
||||
name: String,
|
||||
@@ -147,9 +147,6 @@ fn main() {
|
||||
generate_bindings(module, &rocm_path, preserve_fp_constants);
|
||||
}
|
||||
|
||||
// Generate module imports for dependencies
|
||||
generate_mod_imports(&modules);
|
||||
|
||||
// Print success message
|
||||
println!("cargo:warning=ROCm bindings generated successfully");
|
||||
}
|
||||
@@ -157,15 +154,15 @@ fn main() {
|
||||
// Sort modules so dependencies are processed first
|
||||
fn sort_modules_by_dependencies(modules: &[ModuleConfig]) -> Vec<String> {
|
||||
let mut result = Vec::new();
|
||||
let mut visited = std::collections::HashSet::new();
|
||||
let mut visited = HashSet::new();
|
||||
|
||||
// Recursive function to add a module and its dependencies
|
||||
fn visit(
|
||||
module_name: &str,
|
||||
modules: &[ModuleConfig],
|
||||
result: &mut Vec<String>,
|
||||
visited: &mut std::collections::HashSet<String>,
|
||||
visiting: &mut std::collections::HashSet<String>,
|
||||
visited: &mut HashSet<String>,
|
||||
visiting: &mut HashSet<String>,
|
||||
) {
|
||||
if visited.contains(module_name) {
|
||||
return;
|
||||
@@ -193,7 +190,7 @@ fn sort_modules_by_dependencies(modules: &[ModuleConfig]) -> Vec<String> {
|
||||
}
|
||||
|
||||
// Process all modules
|
||||
let mut visiting = std::collections::HashSet::new();
|
||||
let mut visiting = HashSet::new();
|
||||
for module in modules {
|
||||
visit(
|
||||
&module.name,
|
||||
@@ -322,31 +319,3 @@ fn generate_bindings(module: &ModuleConfig, rocm_path: &str, preserve_fp_constan
|
||||
|
||||
println!("cargo:warning=Generated bindings for {}", module.name);
|
||||
}
|
||||
|
||||
// Generate mod.rs files with proper imports for dependencies
|
||||
fn generate_mod_imports(modules: &[ModuleConfig]) {
|
||||
for module in modules {
|
||||
let out_dir = PathBuf::from("src").join(&module.name);
|
||||
|
||||
// Basic content for all mod.rs files
|
||||
let mut mod_content = format!(
|
||||
"//! Bindings for {}\n//! Auto-generated - do not modify\n\n\
|
||||
pub mod bindings;\n\n\
|
||||
// Re-export all bindings\n\
|
||||
pub use bindings::*;\n",
|
||||
module.name
|
||||
);
|
||||
|
||||
// Add imports for dependencies
|
||||
if !module.dependencies.is_empty() {
|
||||
mod_content.push_str("\n// Import dependencies\n");
|
||||
for dep in &module.dependencies {
|
||||
mod_content.push_str(&format!("pub use crate::{}::*;\n", dep));
|
||||
}
|
||||
}
|
||||
|
||||
// Write the mod.rs file
|
||||
// fs::write(out_dir.join("mod.rs"), mod_content)
|
||||
// .unwrap_or_else(|e| panic!("Couldn't write mod.rs for {}: {:?}", module.name, e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
use crate::error::Result;
|
||||
use crate::hip::kernel::AsKernelArg;
|
||||
use crate::hip::{DeviceMemory, Dim3, Function, Module, Stream, calculate_grid_1d};
|
||||
use std::ffi::c_void;
|
||||
use std::sync::Once;
|
||||
|
||||
static INIT_SORT: Once = Once::new();
|
||||
|
||||
Reference in New Issue
Block a user