diff options
author | Aaron Watry <[email protected]> | 2013-12-12 16:34:09 -0600 |
---|---|---|
committer | Aaron Watry <[email protected]> | 2013-12-23 07:24:50 -0600 |
commit | 8c9a9205d96b5ac0718218bfa952a5b4b6ad939c (patch) | |
tree | 089a1cf74b6d22561955441e93a6dfc38f374d60 /src/gallium/drivers/radeonsi/radeonsi_compute.c | |
parent | a7653c19a3b1adae162864587a7ab1c17ab256e6 (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]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/radeonsi_compute.c')
-rw-r--r-- | src/gallium/drivers/radeonsi/radeonsi_compute.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/gallium/drivers/radeonsi/radeonsi_compute.c b/src/gallium/drivers/radeonsi/radeonsi_compute.c index 2d53f2d9864..214ea3c2552 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_compute.c +++ b/src/gallium/drivers/radeonsi/radeonsi_compute.c @@ -20,6 +20,7 @@ struct si_pipe_compute { struct pipe_resource *global_buffers[MAX_GLOBAL_BUFFERS]; + LLVMContextRef llvm_ctx; }; static void *radeonsi_create_compute_state( @@ -33,6 +34,8 @@ static void *radeonsi_create_compute_state( const unsigned char *code; unsigned i; + program->llvm_ctx = LLVMContextCreate(); + header = cso->prog; code = cso->prog + sizeof(struct pipe_llvm_program_header); @@ -41,13 +44,13 @@ static void *radeonsi_create_compute_state( program->private_size = cso->req_private_mem; program->input_size = cso->req_input_mem; - program->num_kernels = radeon_llvm_get_num_kernels(code, + program->num_kernels = radeon_llvm_get_num_kernels(program->llvm_ctx, code, header->num_bytes); program->kernels = CALLOC(sizeof(struct si_pipe_shader), program->num_kernels); for (i = 0; i < program->num_kernels; i++) { - LLVMModuleRef mod = radeon_llvm_get_kernel_module(i, code, - header->num_bytes); + LLVMModuleRef mod = radeon_llvm_get_kernel_module(program->llvm_ctx, i, + code, header->num_bytes); si_compile_llvm(rctx, &program->kernels[i], mod); LLVMDisposeModule(mod); } @@ -272,6 +275,10 @@ static void si_delete_compute_state(struct pipe_context *ctx, void* state){ FREE(program->kernels); } + if (program->llvm_ctx){ + LLVMContextDispose(program->llvm_ctx); + } + //And then free the program itself. FREE(program); } |