Skip to content

Commit 34a10b9

Browse files
lslusarczykbb-ur
authored andcommitted
Optimize calling UR functions (#20776)
_checkUrResult_ function was made as short as possible by moving away all error handling to a separate non-inlined function and keeping common success path tiny and additionally optimized by compiler __builtin_expect. Also a few more simple inlines were added.
1 parent bdbea83 commit 34a10b9

2 files changed

Lines changed: 1 addition & 8 deletions

File tree

source/loader/ur_lib.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,9 @@
2828
#include <stdlib.h>
2929

3030
namespace ur_lib {
31-
///////////////////////////////////////////////////////////////////////////////
32-
context_t *getContext() { return context_t::get_direct(); }
33-
3431
///////////////////////////////////////////////////////////////////////////////
3532
context_t::context_t() { parseEnvEnabledLayers(); }
3633

37-
///////////////////////////////////////////////////////////////////////////////
38-
context_t::~context_t() {}
39-
4034
void context_t::parseEnvEnabledLayers() {
4135
auto maybeEnableEnvVarVec = getenv_to_vec("UR_ENABLE_LAYERS");
4236
if (!maybeEnableEnvVarVec.has_value()) {

source/loader/ur_lib.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class __urdlllocal context_t : public AtomicSingleton<context_t> {
6161
#endif
6262

6363
context_t();
64-
~context_t();
6564

6665
std::once_flag initOnce;
6766

@@ -117,7 +116,7 @@ class __urdlllocal context_t : public AtomicSingleton<context_t> {
117116
void tearDownLayers() const;
118117
};
119118

120-
context_t *getContext();
119+
inline context_t *getContext() { return context_t::get_direct(); }
121120

122121
ur_result_t urLoaderConfigCreate(ur_loader_config_handle_t *phLoaderConfig);
123122
ur_result_t urLoaderConfigRetain(ur_loader_config_handle_t hLoaderConfig);

0 commit comments

Comments
 (0)