Namespace lsst::base

namespace base

Functions

std::string libraryExtension()

Return filename extension for libraries

Typically “.so” for Linux and “.dylib” for Mac.

std::string getLibraryFilename(std::string const &name)

Get filename for library

We’ll add the typical filename extension for the platform unless the user specifies a “.so” or “.dylib” extension.

bool canLoadLibrary(std::string const &libName)

Parameters
  • libName: Library name

Return whether we can load a library

The proper filename extension will be added to the library name unless one is specified.

template<typename T>
T *loadSymbol(std::string const &libName, std::string const &symName)

Parameters
  • libName: Library name (NOT including “.so” or “.dylib”)

  • symName: Symbol name

Load a symbol from a dynamic library

The proper filename extension will be added to the library name unless one is specified.

No mangling is performed on the symbol name.

bool haveThreads()

Are threaded packages available?

void setNumThreads(unsigned int numThreads)

Set number of threads to use

Exceptions

unsigned int getNumThreads()

Get maximum number of threads we might use

Returns the maximum value of the number of threads being used by the threading libraries that are available.

bool disableImplicitThreading()

Disable threading that has not been set explicitly

Some threaded packages implicitly use multiple threads if the user doesn’t explicitly state the number of desired threads. However, this can interfere with operations that are parallelised at a higher level. This function will disable threading unless the user has explicitly specified the number of desired threads through environment variables.

This behavior may be disabled by setting the environment variable specified by allowEnvvar.

This is principally intended for Linux machines (we explicitly load .so dynamic libraries); MacOS has its own way of doing threading (Grand Central Dispatch) that throttles threads to avoid overwhelming the machine.

@ return whether we disabled threading

std::map<std::string, std::string> getRuntimeVersions()

Return version strings for dependencies

It is not clever, and only returns versions of packages declared in an internal list.

Returns a map of product:version.

std::string getCfitsioVersion()
std::string getFftwVersion()
std::string getWcslibVersion()
std::string getGslVersion()

Variables

bool const haveOpenBlas

Is OpenBLAS available?

bool const haveMkl

Is MKL available?

std::string const allowEnvvar = "LSST_ALLOW_IMPLICIT_THREADS"

Environment variable to allow implicit threading

Used by disableImplicitThreading.

class LibraryException : public runtime_error
#include <library.h>

Unable to load library.

class ModuleImporter
#include <ModuleImporter.h>

Base class that defines an interface for importing Python modules.

The default implementation (defined in the source file) simply returns false, indicating that it can’t import the given module. The functional implementation is in the ioLib Swig module, which is installed when that module is imported. That machinery keeps us from calling Python C-API functions from standalone C++ binaries that aren’t linked with Python.

class NoThreadsException : public runtime_error
#include <threads.h>

No threading library is available.