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

multiple gpu streams created when lowering gpu to gpux #797

Open
Menooker opened this issue Jul 1, 2024 · 1 comment
Open

multiple gpu streams created when lowering gpu to gpux #797

Menooker opened this issue Jul 1, 2024 · 1 comment

Comments

@Menooker
Copy link

Menooker commented Jul 1, 2024

See opt result of test/Integration/Dialect/XeGPU/vector_insert_1.mlir.

when main() calls test() and both functions access GPU shared memory, IMEX will geenerate code like

func test(...) -> memref<...> {
   s1 = gpuStreamCreate(...)
   ret = gpuMemAlloc(s1, ...)
   gpuLaunchKernel(ret, ...)
   gpuWait()
   gpuStreamDestroy(s1)
   return ret
}

func main() {
   s2 = gpuStreamCreate(...)
   v = test(...)
   gpuMemFree(s2, v)
   gpuStreamDestroy(s2)
}

Note that it creates 2 streams s1 and s2. Also note that, the result of test is allocated from s1, which is already destroyed at the end of test. And we are using s2 to free the memory of the result.

This happens to work in L0 and Sycl runtime, but I guess it is not actually legal in them to create memory in one stream and free it in another. This will cause an error in opencl runtime, BTW.

@Menooker Menooker changed the title multiple gpu stream created when lowering gpu to gpux multiple gpu streams created when lowering gpu to gpux Jul 1, 2024
@Jianhui-Li
Copy link
Contributor

Jianhui-Li commented Jul 11, 2024

@silee2 could you please take a look? Is the behavior expected, or is it a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants