mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd:🆑 Load the pipe dynamically after configuring environment.
This commit is contained in:
parent
c34045c9d8
commit
3549ab473a
3 changed files with 39 additions and 6 deletions
|
@ -25,8 +25,9 @@ namespace ircd::cl
|
|||
struct data;
|
||||
struct work;
|
||||
|
||||
extern const info::versions version_api;
|
||||
extern info::versions version_abi;
|
||||
extern log::log log;
|
||||
extern const info::versions version_api, version_abi;
|
||||
|
||||
string_view reflect_error(const int code) noexcept;
|
||||
|
||||
|
|
|
@ -108,7 +108,6 @@ libircd_la_LIBADD = \
|
|||
@JS_LIBS@ \
|
||||
@ICU_LIBS@ \
|
||||
@BOOST_LIBS@ \
|
||||
@OPENCL_LIBS@ \
|
||||
@PBC_LIBS@ \
|
||||
@SSL_LIBS@ \
|
||||
@CRYPTO_LIBS@ \
|
||||
|
|
41
ircd/cl.cc
41
ircd/cl.cc
|
@ -8,6 +8,7 @@
|
|||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <CL/cl.h>
|
||||
|
||||
// Util
|
||||
|
@ -23,13 +24,21 @@ namespace ircd::cl
|
|||
namespace ircd::cl
|
||||
{
|
||||
static const size_t
|
||||
OPTION_MAX {8},
|
||||
PLATFORM_MAX {8},
|
||||
DEVICE_MAX {8};
|
||||
|
||||
static uint
|
||||
options,
|
||||
platforms,
|
||||
devices[PLATFORM_MAX];
|
||||
|
||||
static char
|
||||
option[OPTION_MAX][256];
|
||||
|
||||
static void
|
||||
*linkage;
|
||||
|
||||
static cl_platform_id
|
||||
platform[PLATFORM_MAX];
|
||||
|
||||
|
@ -67,10 +76,7 @@ ircd::cl::version_api
|
|||
decltype(ircd::cl::version_abi)
|
||||
ircd::cl::version_abi
|
||||
{
|
||||
"OpenCL", info::versions::ABI, 0,
|
||||
{
|
||||
0, 0, 0
|
||||
}
|
||||
"OpenCL", info::versions::ABI
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -79,6 +85,27 @@ ircd::cl::version_abi
|
|||
|
||||
ircd::cl::init::init()
|
||||
{
|
||||
const ctx::posix::enable_pthread enable_pthread;
|
||||
|
||||
// Setup options
|
||||
strlcpy{option[options++], "LP_NUM_THREADS=0"};
|
||||
strlcpy{option[options++], "MESA_GLSL_CACHE_DISABLE=true"};
|
||||
strlcpy{option[options++], "AMD_DEBUG=nogfx"};
|
||||
assert(options <= OPTION_MAX);
|
||||
|
||||
// Configure options into the environment. TODO: XXX don't overwrite
|
||||
while(options--)
|
||||
sys::call(putenv, option[options]);
|
||||
|
||||
// Load the pipe.
|
||||
assert(!linkage);
|
||||
if(!(linkage = dlopen("libOpenCL.so", RTLD_LAZY | RTLD_GLOBAL)))
|
||||
return;
|
||||
|
||||
// OpenCL sez platform=null is implementation defined.
|
||||
info(clGetPlatformInfo, nullptr, CL_PLATFORM_VERSION, version_abi.string);
|
||||
|
||||
// Get the platforms.
|
||||
call(clGetPlatformIDs, PLATFORM_MAX, platform, &platforms);
|
||||
|
||||
char buf[4][128];
|
||||
|
@ -148,6 +175,10 @@ ircd::cl::init::init()
|
|||
ircd::cl::init::~init()
|
||||
noexcept
|
||||
{
|
||||
if(!linkage)
|
||||
return;
|
||||
|
||||
const ctx::posix::enable_pthread enable_pthread;
|
||||
if(primary)
|
||||
{
|
||||
log::debug
|
||||
|
@ -171,6 +202,8 @@ noexcept
|
|||
call(clReleaseContext, primary);
|
||||
primary = nullptr;
|
||||
}
|
||||
|
||||
dlclose(linkage);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue