Skip to content

Commit 477e535

Browse files
allenwang28meta-codesync[bot]
authored andcommitted
Moves a few i8 to c_char for ARM compatible tensor engine builds (#1814)
Summary: Pull Request resolved: #1814 As title. For the interested, Claude mentions that the C standard says `char` signedness is implementation-defined. x86_64 for instance has `char` be signed - therefore all of our usage of char as i8 was correct. But on aarch64, it's unsigned by default. Without this change, you see a lot of errors like this: ``` error[E0308]: mismatched types --> monarch_rdma/src/rdma_manager_actor.rs:398:57 | 398 | let pci_addr = std::ffi::CStr::from_ptr(pci_addr_buf.as_ptr()) | ------------------------ ^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8` | | | arguments to this function are incorrect | = note: expected raw pointer `*const u8` found raw pointer `*const i8` note: associated function defined here ``` Reviewed By: shayne-fletcher Differential Revision: D86711698 fbshipit-source-id: 0ffb7ec0a226734c50019adc913ef93c46efd11e
1 parent f5a0c71 commit 477e535

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

monarch_rdma/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
macro_rules! cu_check {
1111
($result:expr) => {
1212
if $result != cuda_sys::CUresult::CUDA_SUCCESS {
13-
let mut error_string: *const i8 = std::ptr::null();
13+
let mut error_string: *const std::os::raw::c_char = std::ptr::null();
1414
cuda_sys::cuGetErrorString($result, &mut error_string);
1515
panic!(
1616
"cuda failure {}:{} {:?} '{}'",

monarch_rdma/src/rdma_manager_actor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl RdmaManagerActor {
378378

379379
if is_cuda {
380380
// Use rdmaxcel utility to get PCI address from CUDA pointer
381-
let mut pci_addr_buf = [0i8; 16]; // Enough space for "ffff:ff:ff.0\0"
381+
let mut pci_addr_buf: [std::os::raw::c_char; 16] = [0; 16]; // Enough space for "ffff:ff:ff.0\0"
382382
let err = rdmaxcel_sys::get_cuda_pci_address_from_ptr(
383383
addr as u64,
384384
pci_addr_buf.as_mut_ptr(),

nccl-sys/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,20 @@ mod inner {
5656
pub internal: [::std::os::raw::c_char; 128usize],
5757
}
5858

59-
fn deserialize_array<'de, D>(deserializer: D) -> Result<[i8; 128], D::Error>
59+
fn deserialize_array<'de, D>(deserializer: D) -> Result<[::std::os::raw::c_char; 128], D::Error>
6060
where
6161
D: Deserializer<'de>,
6262
{
63-
let vec: Vec<i8> = Deserialize::deserialize(deserializer)?;
64-
vec.try_into().map_err(|v: Vec<i8>| {
63+
let vec: Vec<::std::os::raw::c_char> = Deserialize::deserialize(deserializer)?;
64+
vec.try_into().map_err(|v: Vec<::std::os::raw::c_char>| {
6565
serde::de::Error::invalid_length(v.len(), &"expected an array of length 128")
6666
})
6767
}
6868

69-
fn serialize_array<S>(array: &[i8; 128], serializer: S) -> Result<S::Ok, S::Error>
69+
fn serialize_array<S>(
70+
array: &[::std::os::raw::c_char; 128],
71+
serializer: S,
72+
) -> Result<S::Ok, S::Error>
7073
where
7174
S: Serializer,
7275
{

0 commit comments

Comments
 (0)