oneAPI-spec icon indicating copy to clipboard operation
oneAPI-spec copied to clipboard

Global variables

Open WeiqunZhang opened this issue 5 years ago • 2 comments

Could DPC++ support global variables in device memory and USM, and a memcpy function for copying data from host to the global variable?

WeiqunZhang avatar Apr 28 '20 19:04 WeiqunZhang

Would Codeplay's extension proposal https://github.com/codeplaysoftware/standards-proposals/pull/132 address your use-case?

rolandschulz avatar Oct 16 '20 00:10 rolandschulz

@rolandschulz Thanks for pointing to the extension proposal. It addresses some of our usages. But it's not clear if it works for the following example.

// File: parm.H
extern sycl::symbol<int> gv;
inline int f_using_gv () { return gv; }
// File: parm.cpp
#include "parm.H"
sycl::symbol<int> gv;
// functions for initializing gv via copying from host or launching a kernel to set gv.
// File: main.cpp
#include "parm.H"
int main(...) {
    sycl::queue q(...);
    q.submit(...
        int v = f_using_gv();
    );
}

WeiqunZhang avatar Oct 17 '20 18:10 WeiqunZhang