summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600
diff options
context:
space:
mode:
authorAaron Watry <[email protected]>2013-12-12 16:34:09 -0600
committerCarl Worth <[email protected]>2014-01-02 15:57:41 -0800
commit87cdd13324a070aa36424bead9dc2c053da9c301 (patch)
tree4d6bad04755a166a433277ee41aaaa1a64a31af5 /src/gallium/drivers/r600
parentb2ea582679459f593c15daabf9c0563dcdb768c1 (diff)
radeon/compute: Stop leaking LLVMContexts in radeon_llvm_parse_bitcode
Previously we were creating a new LLVMContext every time that we called radeon_llvm_parse_bitcode, which caused us to leak the context every time that we compiled a CL program. Sadly, we can't dispose of the LLVMContext at the point that it was being created because evergreen_launch_grid (and possibly the SI equivalent) was assuming that the context used to compile the kernels was still available. Now, we'll create a new LLVMContext when creating EG/SI compute state, store it there, and pass it to all of the places that need it. The LLVM Context gets destroyed when we delete the EG/SI compute state. Reviewed-by: Tom Stellard <[email protected]> CC: "10.0" <[email protected]> (cherry picked from commit 8c9a9205d96b5ac0718218bfa952a5b4b6ad939c)
Diffstat (limited to 'src/gallium/drivers/r600')
-rw-r--r--src/gallium/drivers/r600/evergreen_compute.c18
-rw-r--r--src/gallium/drivers/r600/evergreen_compute_internal.h4
2 files changed, 19 insertions, 3 deletions
diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
index d668c8e2746..f0f537cd8e2 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -204,6 +204,8 @@ void *evergreen_create_compute_state(
const unsigned char * code;
unsigned i;
+ shader->llvm_ctx = LLVMContextCreate();
+
COMPUTE_DBG(ctx->screen, "*** evergreen_create_compute_state\n");
header = cso->prog;
@@ -216,13 +218,14 @@ void *evergreen_create_compute_state(
shader->input_size = cso->req_input_mem;
#ifdef HAVE_OPENCL
- shader->num_kernels = radeon_llvm_get_num_kernels(code, header->num_bytes);
+ shader->num_kernels = radeon_llvm_get_num_kernels(shader->llvm_ctx, code,
+ header->num_bytes);
shader->kernels = CALLOC(sizeof(struct r600_kernel), shader->num_kernels);
for (i = 0; i < shader->num_kernels; i++) {
struct r600_kernel *kernel = &shader->kernels[i];
- kernel->llvm_module = radeon_llvm_get_kernel_module(i, code,
- header->num_bytes);
+ kernel->llvm_module = radeon_llvm_get_kernel_module(shader->llvm_ctx, i,
+ code, header->num_bytes);
}
#endif
return shader;
@@ -232,6 +235,15 @@ void evergreen_delete_compute_state(struct pipe_context *ctx, void* state)
{
struct r600_pipe_compute *shader = (struct r600_pipe_compute *)state;
+ if (!shader)
+ return;
+
+#ifdef HAVE_OPENCL
+ if (shader->llvm_ctx){
+ LLVMContextDispose(shader->llvm_ctx);
+ }
+#endif
+
free(shader);
}
diff --git a/src/gallium/drivers/r600/evergreen_compute_internal.h b/src/gallium/drivers/r600/evergreen_compute_internal.h
index c524da2b84d..0929d8dcf27 100644
--- a/src/gallium/drivers/r600/evergreen_compute_internal.h
+++ b/src/gallium/drivers/r600/evergreen_compute_internal.h
@@ -47,6 +47,10 @@ struct r600_pipe_compute {
unsigned private_size;
unsigned input_size;
struct r600_resource *kernel_param;
+
+#ifdef HAVE_OPENCL
+ LLVMContextRef llvm_ctx;
+#endif
};
struct r600_resource* r600_compute_buffer_alloc_vram(struct r600_screen *screen, unsigned size);