Added platform option.
This commit is contained in:
parent
476e5dcb18
commit
166a68244e
9 changed files with 194 additions and 26 deletions
|
@ -123,26 +123,36 @@ static setKernelArg_t pSetKernelArg = nu
|
|||
#define DLSYM(x) if (uv_dlsym(&oclLib, k##x, reinterpret_cast<void**>(&p##x)) == -1) { return false; }
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
bool OclLib::m_initialized = false;
|
||||
bool OclLib::m_ready = false;
|
||||
String OclLib::m_loader;
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
bool xmrig::OclLib::init(const char *fileName)
|
||||
{
|
||||
if (uv_dlopen(fileName == nullptr ? defaultLoader() : fileName, &oclLib) == -1 || !load()) {
|
||||
LOG_ERR("Failed to load OpenCL runtime: %s", uv_dlerror(&oclLib));
|
||||
return false;
|
||||
if (!m_initialized) {
|
||||
m_loader = fileName == nullptr ? defaultLoader() : fileName;
|
||||
m_ready = uv_dlopen(m_loader, &oclLib) == 0 && load();
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return m_ready;
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::OclLib::defaultLoader()
|
||||
const char *xmrig::OclLib::lastError()
|
||||
{
|
||||
# if defined(__APPLE__)
|
||||
return "/System/Library/Frameworks/OpenCL.framework/OpenCL";
|
||||
# elif defined(_WIN32)
|
||||
return "OpenCL.dll";
|
||||
# else
|
||||
return "libOpenCL.so";
|
||||
# endif
|
||||
return uv_dlerror(&oclLib);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclLib::close()
|
||||
{
|
||||
uv_dlclose(&oclLib);
|
||||
}
|
||||
|
||||
|
||||
|
@ -181,6 +191,18 @@ bool xmrig::OclLib::load()
|
|||
}
|
||||
|
||||
|
||||
const char *xmrig::OclLib::defaultLoader()
|
||||
{
|
||||
# if defined(__APPLE__)
|
||||
return "/System/Library/Frameworks/OpenCL.framework/OpenCL";
|
||||
# elif defined(_WIN32)
|
||||
return "OpenCL.dll";
|
||||
# else
|
||||
return "libOpenCL.so";
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
cl_command_queue xmrig::OclLib::createCommandQueue(cl_context context, cl_device_id device, cl_int *errcode_ret)
|
||||
{
|
||||
cl_command_queue result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue