clSetKernelArg and variable lifetime

How does OpenCL specification say about the length of lifetime of a variable which passed for clSetKernelArg?

For example,

{
    int x;
    clSetKernelArg(0, sizeof(x), &x);
}
clEnqueueNDRangeKernel(...);

The variable x is dead when kernel execution, is this fine?

I know it works on the current major implementations (e.g. CUDA, ROCm). But we need to think about the portability based on the specification because we’re using “open standard”.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.