#huawei #gpu #monitoring #managment #hardware #api-bindings

hw_dcmi_wrapper

A safe and ergonomic Rust wrapper for the Huawei DCMI API

3 releases

new 0.0.3 Feb 7, 2025
0.0.2 Feb 6, 2025
0.0.1 Feb 6, 2025

#187 in Hardware support

Download history 376/week @ 2025-02-05

376 downloads per month

MIT/Apache

97KB
2K SLoC

HW_DCMI_WRAPPER

Crates.io version Crates.io downloads Docs.rs docs

中文文档

Description

The HW_DCMI_WRAPPER project provides a set of third-party FFI (Foreign Function Interface) bindings for interacting with Huawei DCMI. This repository contains two main packages:

  1. hw_dcmi_wrapper: Provides safe and user-friendly bindings for integrating DCMI functionality into your applications.
  2. hw_dcmi_wrapper_sys: Offers low-level, unsafe bindings that provide direct access to the underlying DCMI system calls.

Getting Started

Prerequisites

  • Ubuntu 22.04 or later
  • Atlas 6.0.0 or newer with DCMI support installed
  • Required dependencies:
    • DCMI shared library
    • Ascend driver

Default Configuration

By default, the library searches for DCMI components in the /usr/local/dcmi directory. You can override this path by setting the HW_DCMI_PATH environment variable.

If you want to regenerate bindings, you can set HW_DCMI_BINDING_BUILD to true to regenerate bindings, the generated bindings will be saved in:

  • Static link: hw_dcmi_wrapper_sys/src/bindings.rs
  • Dynamic link: hw_dcmi_wrapper_sys/src/bindings_dyn.rs

Example Usage

  • Before using any DCMI API, you need to initialize the library first. You can Initialize the library with Dcmi::init
  • Most API interfaces are encapsulated to conform to ergonomics, such as Card: Query_cards returned a Vec<Card>.
  • If you are confident that the parameters are correct, you can use Card::new_uncheckto create a Card instance.

Please refer to the document for details( https://docs.rs/hw_dcmi_wrapper )

use hw_dcmi_wrapper::dcmi;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let dcmi = DCMI::init().unwrap();

    let dcmi_version = dcmi.get_dcmi_version().unwrap();
    println!("DCMI version: {}", dcmi_version);

    let cards = Card::query_cards(&dcmi).unwrap();
    println!("Card list: {:?}", cards);
}

Version Strategy

  • This project follows the semantic version Standardization

  • The version number format for this project is <major>< minor>.<patch>, The rule for increasing version numbers is as follows:

    • Major: Incompatible API changes
    • Minor: Added functionality for backward compatibility
    • Patch: Fix backward compatibility issues
  • When the project is in version '0.0.z', any change in version number may result in incompatible API changes.

  • When the project is in version '0.y.z', only increasing 'y' will result in incompatible API changes.

Project Status

Currently `Hw_dcmi_wrapper is under development, please refer to the API mapping table below for details.

Due to the instability of the DCMI API, this project will always be in version 0. y. z to adapt to possible changes in the DCMI API.

API Mapping

Device Management Interface

hw_dcmi_wrapper DCMI API
dcmi_init DCMI::new
dcmi_get_dcmi_version DCMI::get_dcmi_version
dcmi_get_driver_version DCMI::get_driver_version
dcmi_get_card_list Card::query_cards
dcmi_get_device_num_in_card Card::get_chip_num
dcmi_get_device_id_in_card Card::get_chips
dcmi_get_device_type Chip::get_type
dcmi_get_device_chip_info Chip::get_info
dcmi_get_device_pcie_info Chip::get_pcie_info
dcmi_get_device_pcie_info_v2 Chip::get_domain_pcie_info
dcmi_get_device_board_info Chip::get_board_info
dcmi_get_device_elabel_info Chip::get_elabel_info
dcmi_get_device_power_info Chip::get_power_info
dcmi_get_device_die_v2 Chip::get_die_info
dcmi_get_device_health Chip::get_health
dcmi_get_driver_health DCMI::get_driver_health
dcmi_get_device_errorcode_v2 Chip::get_error_code
dcmi_get_driver_errorcode DCMI::get_driver_error_code
dcmi_get_device_errorcode_string Chip::get_error_code_string
dcmi_get_device_flash_count Chip::get_flash_count
dcmi_get_device_flash_info_v2 Chip::get_flash_info
dcmi_get_device_aicore_info Chip::get_ai_core_info
dcmi_get_device_aicpu_info Chip::get_ai_cpu_info
dcmi_get_device_system_time Chip::get_system_time
dcmi_get_device_temperature Chip::get_temperature
dcmi_get_device_voltage Chip::get_voltage
dcmi_get_device_pcie_error_cnt Chip::get_pcie_error_cnt
dcmi_get_device_ecc_info Chip::get_ecc_info
dcmi_get_device_frequency Chip::get_frequency
dcmi_get_device_hbm_info Chip::get_hbm_info
dcmi_get_device_memory_info_v3 Chip::get_memory_info
dcmi_get_device_utilization_rate Chip::get_utilization_rate
dcmi_get_device_sensor_info Chip::get_sensor_info
dcmi_set_container_service_enable DCMI::set_container_service_enable
dcmi_get_device_board_id Chip::get_board_id
dcmi_get_device_component_count Chip::get_component_count
dcmi_get_device_component_list Chip::get_component_list
dcmi_get_device_component_static_version Chip::get_component_static_version
dcmi_get_device_cgroup_info Chip::get_cgroup_info
dcmi_get_device_llc_perf_para Chip::get_llc_perf

Compute power splitting interface

hw_dcmi_wrapper DCMI API
dcmi_set_vdevice_mode VChip::set_compute_power_splitting_mode
dcmi_get_vdevice_mode VChip::get_compute_power_splitting_mode
dcmi_create_vdevice VChip::create
dcmi_set_vnpu_config_recover_mode VChip::set_recovery_mode
dcmi_get_vnpu_config_recover_mode VChip::get_recovery_mode
dcmi_set_destroy_vdevice VChip::destroyVChip::destory_all

License

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.5–7.5MB
~60K SLoC