Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "currently only pointers to arrays supported" only when partial evaluation is not used #52

Open
ergawy opened this issue Sep 1, 2016 · 2 comments

Comments

@ergawy
Copy link

ergawy commented Sep 1, 2016

The following code,

extern "thorin" {
    fn nvvm(i32, (i32, i32, i32), (i32, i32, i32), fn() -> ()) -> ();
}

extern "C" {
    fn thorin_alloc(i32, i64) -> &i8;
}

fn get_element_addr(mut data: &[i8], idx: i32) -> &[i8] { data }

fn call_me() -> () {
    let d_in_buf = thorin_alloc(1, 10i64) as &[i8];

    with nvvm(0, (1,1,1), (1,1,1)) {
        //@get_element_addr(d_in_buf, 0);
        get_element_addr(d_in_buf, 0);
    }
}

fn main() -> i32 {
    call_me();
    0
}

produces this compilation runtime error:

E:\anydsl\thorin\src\thorin\be\llvm\runtime.cpp: 90: currently only pointers to arrays supported as kernel argument at 'broken.impala:6 col 5 - 37'; argument has different type: qs8*

This happens only if get_element_addr is called without partial evaluation.

@richardmembarth
Copy link
Member

This is actually not a bug ... we expect pointers on the GPU to reside in the global address space, e.g. &[1][i8]. In case you modify your example to use the correct address space, we can generate code for it:

extern "thorin" {
    fn nvvm(i32, (i32, i32, i32), (i32, i32, i32), fn() -> ()) -> ();
}

extern "C" {
    fn thorin_alloc(i32, i64) -> &i8;
}

fn get_element_addr(mut data: &[1][i8], idx: i32) -> &[1][i8] { data }

fn call_me() -> () {
    let d_in_buf = thorin_alloc(1, 10i64) as &[1][i8];

    with nvvm(0, (1,1,1), (1,1,1)) {
        //@get_element_addr(d_in_buf, 0);
        get_element_addr(d_in_buf, 0);
    }
}

fn main() -> i32 {
    call_me();
    0
}

Our current type system doesn't recognize that you're passing a CPU pointer to the GPU, but that is on our agenda.

@leissa
Copy link
Member

leissa commented Sep 2, 2016

We should keep this issue open until our type system can deal with this.

NeuralCoder3 pushed a commit to NeuralCoder3/thorin-2-autodiff-legacy that referenced this issue Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants