radv: using tls to store llvm related info and speed up compiles (v10)
This uses the common compiler passes abstraction to help radv avoid fixed cost compiler overheads. This uses a linked list per thread stored in thread local storage, with an entry in the list for each target machine. This should remove all the fixed overheads setup costs of creating the pass manager each time. This takes a demo app time to compile the radv meta shaders on nocache and exit from 1.7s to 1s. It also has been reported to take the startup time of uncached shaders on RoTR from 12m24s to 11m35s (Alex) v2: fix llvm6 build, inline emit function, handle multiple targets in one thread v3: rebase and port onto new structure v4: rename some vars (Bas) v5: drag all code into radv for now, we can refactor it out later for radeonsi if we make it shareable v6: use a bit more C++ in the wrapper v7: logic bugs fixed so it actually runs again. v8: rebase on top of radeonsi changes. v9: drop some C++ headers, cleanup list entry v10: use pop_back (didn't have enough caffeine) Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "radv_debug.h"
|
||||
#include "radv_private.h"
|
||||
#include "radv_shader.h"
|
||||
#include "radv_shader_helper.h"
|
||||
#include "nir/nir.h"
|
||||
#include "nir/nir_builder.h"
|
||||
#include "spirv/nir_spirv.h"
|
||||
@@ -542,7 +543,7 @@ shader_variant_create(struct radv_device *device,
|
||||
struct radv_shader_variant *variant;
|
||||
struct ac_shader_binary binary;
|
||||
struct ac_llvm_compiler ac_llvm;
|
||||
|
||||
bool thread_compiler;
|
||||
variant = calloc(1, sizeof(struct radv_shader_variant));
|
||||
if (!variant)
|
||||
return NULL;
|
||||
@@ -564,8 +565,11 @@ shader_variant_create(struct radv_device *device,
|
||||
if (options->check_ir)
|
||||
tm_options |= AC_TM_CHECK_IR;
|
||||
|
||||
thread_compiler = !(device->instance->debug_flags & RADV_DEBUG_NOTHREADLLVM);
|
||||
radv_init_llvm_once();
|
||||
ac_init_llvm_compiler(&ac_llvm, false, chip_family, tm_options);
|
||||
radv_init_llvm_compiler(&ac_llvm, false,
|
||||
thread_compiler,
|
||||
chip_family, tm_options);
|
||||
if (gs_copy_shader) {
|
||||
assert(shader_count == 1);
|
||||
radv_compile_gs_copy_shader(&ac_llvm, *shaders, &binary,
|
||||
@@ -577,7 +581,7 @@ shader_variant_create(struct radv_device *device,
|
||||
options);
|
||||
}
|
||||
|
||||
ac_destroy_llvm_compiler(&ac_llvm);
|
||||
radv_destroy_llvm_compiler(&ac_llvm, thread_compiler);
|
||||
|
||||
radv_fill_shader_variant(device, variant, &binary, stage);
|
||||
|
||||
|
Reference in New Issue
Block a user