Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

core::slice in kernel #16

Closed
wants to merge 8 commits into from
Closed

core::slice in kernel #16

wants to merge 8 commits into from

Conversation

termoshtt
Copy link
Owner

This PR try to use core::slice in a kernel function

#[kernel]
#[depends("accel-core" = "0.2.0-alpha")]
pub unsafe fn add(a: &[f64], b: &[f64], c: &mut [f64]) {
    let i = accel_core::index() as usize;
    let n = c.len();
    if i < n {
        c[i] = a[i] + b[i]
    }
}

Problem

This kernel yields an error about PTX:

called `Result::unwrap()` on an `Err` value: cudaError(CUDA_ERROR_INVALID_PTX)

PTX-builder links rust code into LLVM byte-code (kernel.bc) while macro #[kernel] of accel-derive, and it will be loaded into accel::Module. "Invalid PTX" erro occurs on this loading. To get more information about how this PTX is invalid, I have tried to load PTX file manually:

llc -mcpu=sm_20 kernel.bc -o kernel.ptx  # compile LLVM byptecode to PTX
nvcc --cubin kernel.ptx  # Convert PTX to cubin

llc works, but nvcc raises an error:

ptxas fatal   : Unresolved extern function '_ZN4core9panicking18panic_bounds_check17h476c69b1512db11aE'

This function seems to be core::panicking::panic_bounds_check, which should be contained in libcore.
(#11 is opened here on Jan, and I still stay here)

@termoshtt
Copy link
Owner Author

termoshtt commented Mar 19, 2018

Link error about panic_bounds_check has been resolved, but the result of add is still invalid (´・ω・`)

a = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0]
b = [0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0]
c = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

@termoshtt termoshtt changed the title WIP: core::slice in kernel core::slice in kernel Mar 31, 2018
@sandeep-datta
Copy link

Can you try again with sm_30 as the target arch? Sm_20 has been deprecated.

@termoshtt
Copy link
Owner Author

@termoshtt termoshtt closed this Jan 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants