Skip to content
Snippets Groups Projects
Commit 402bc6bc authored by Carsten Patzke's avatar Carsten Patzke
Browse files

Added env ASAPO_LIBFABRIC_LIBRARY to override lib path

parent c7161722
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#ifdef LIBFABRIC_ENABLED #ifdef LIBFABRIC_ENABLED
#include <dlfcn.h> #include <dlfcn.h>
#include <mutex> #include <mutex>
#include <iostream>
#include "fabric_factory_impl.h" #include "fabric_factory_impl.h"
#include "fabric_function_map.h" #include "fabric_function_map.h"
#endif #endif
...@@ -19,26 +20,36 @@ std::unique_ptr<FabricFactory> asapo::fabric::GenerateDefaultFabricFactory() { ...@@ -19,26 +20,36 @@ std::unique_ptr<FabricFactory> asapo::fabric::GenerateDefaultFabricFactory() {
return std::unique_ptr<FabricFactory>(new FabricFactoryImpl()); return std::unique_ptr<FabricFactory>(new FabricFactoryImpl());
} }
void* handle = dlopen("libfabric.so.1", RTLD_LAZY); const char* libfabric_path_override = std::getenv("ASAPO_LIBFABRIC_LIBRARY");
if (handle) { void* handle = nullptr;
if (libfabric_path_override) {
handle = dlopen(libfabric_path_override, RTLD_LAZY);
if (!handle) {
std::cerr << "WARN: 'ASAPO_LIBFABRIC_LIBRARY' was set, but failed to open. Reason: '" << dlerror() << "'. Fallback to normal path." << std::endl;
}
}
if (!handle) {
handle = dlopen("libfabric.so.1", RTLD_LAZY); // Try release v1.xx
}
if (!handle) {
return std::unique_ptr<FabricFactory>(new FabricFactoryNotSupported(FabricErrorTemplates::kLibraryNotFoundError));
}
#define ADD_FABRIC_CALL(fName) do { if (!(*((void**)&gffm().fName) = dlsym(handle, #fName))) goto functionNotFoundError; } while(0) #define ADD_FABRIC_CALL(fName) do { if (!(*((void**)&gffm().fName) = dlsym(handle, #fName))) goto functionNotFoundError; } while(0)
ADD_FABRIC_CALL(fi_version); ADD_FABRIC_CALL(fi_version);
ADD_FABRIC_CALL(fi_dupinfo); ADD_FABRIC_CALL(fi_dupinfo);
ADD_FABRIC_CALL(fi_freeinfo); ADD_FABRIC_CALL(fi_freeinfo);
ADD_FABRIC_CALL(fi_getinfo); ADD_FABRIC_CALL(fi_getinfo);
ADD_FABRIC_CALL(fi_fabric); ADD_FABRIC_CALL(fi_fabric);
ADD_FABRIC_CALL(fi_strerror); ADD_FABRIC_CALL(fi_strerror);
#undef ADD_FABRIC_CALL #undef ADD_FABRIC_CALL
gffm().is_init_ = true; gffm().is_init_ = true;
return std::unique_ptr<FabricFactory>(new FabricFactoryImpl()); return std::unique_ptr<FabricFactory>(new FabricFactoryImpl());
functionNotFoundError: functionNotFoundError:
dlclose(handle); dlclose(handle);
return std::unique_ptr<FabricFactory>(new FabricFactoryNotSupported(FabricErrorTemplates::kLibraryCompatibilityError)); return std::unique_ptr<FabricFactory>(new FabricFactoryNotSupported(FabricErrorTemplates::kLibraryCompatibilityError));
} else {
return std::unique_ptr<FabricFactory>(new FabricFactoryNotSupported(FabricErrorTemplates::kLibraryNotFoundError));
}
#endif #endif
return std::unique_ptr<FabricFactory>(new FabricFactoryNotSupported(FabricErrorTemplates::kNotSupportedOnBuildError)); return std::unique_ptr<FabricFactory>(new FabricFactoryNotSupported(FabricErrorTemplates::kNotSupportedOnBuildError));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment