[GPUJIT] Teach GPUJIT to use a pre-existing CUDA context if available.
authorSiddharth Bhat <siddu.druid@gmail.com>
Wed, 2 Aug 2017 09:19:42 +0000 (09:19 +0000)
committerSiddharth Bhat <siddu.druid@gmail.com>
Wed, 2 Aug 2017 09:19:42 +0000 (09:19 +0000)
commitb1a52abd87c15f3b32f86153b33e6f48ccd8d705
tree8c05ad373c039a6e3786d1e4ec3cdf5c842039cd
parent574b753bfd3adb9d17341acd48dd1bb6a57ec1f3
[GPUJIT] Teach GPUJIT to use a pre-existing CUDA context if available.

On mixing the driver and runtime APIs, it is quite possible that a
context already exists due to runtime API usage. In this case, Polly should
try to use the same context.

This patch teaches GPUJIT to detect that a context exists and how to
pick up this context.

Without this, calling `cudaMallocManaged`, for example, before a
polly-generated kernel launch causes P100 to *hang*.

This is a part of (https://reviews.llvm.org/D35991) that was extracted
out.

Differential Revision: https://reviews.llvm.org/D36162

llvm-svn: 309802
polly/tools/GPURuntime/GPUJIT.c