132 void* Foam::codedBase::loadLibrary
134 const fileName& libPath,
135 const std::string& funcName,
136 const dynamicCodeContext& context
141 void* handle = libs().open(libPath,
false);
153 const bool ok = libs().loadHook(handle, funcName,
false);
158 <<
"Failed symbol lookup " << funcName.c_str() <<
nl 159 <<
"from " << libPath <<
nl 163 if (!libs().close(libPath,
false))
166 <<
"Failed unloading library " << libPath <<
nl 175 void Foam::codedBase::unloadLibrary
177 const fileName& libPath,
178 const std::string& funcName,
179 const dynamicCodeContext& context
182 void* handle = libs().open(libPath,
false);
192 const bool ok = libs().unloadHook(handle, funcName,
false);
197 <<
"Failed looking up symbol " << funcName <<
nl 198 <<
"from " << libPath <<
nl;
201 if (!libs().close(libPath,
false))
204 <<
"Failed unloading library " << libPath <<
nl 210 void Foam::codedBase::createLibrary
212 dynamicCode& dynCode,
213 const dynamicCodeContext& context
227 && !dynCode.upToDate(context)
231 dynCode.reset(context);
233 this->prepare(dynCode, context);
235 if (!dynCode.copyOrCreateFiles(
true))
238 <<
"Failed writing files for" <<
nl 239 << dynCode.libRelPath() <<
nl 243 if (!dynCode.wmakeLibso())
246 <<
"Failed wmake " << dynCode.libRelPath() <<
nl 257 const fileName libPath = dynCode.libPath();
279 context_.setCodeContext(
dict);
285 context_.append(str);
297 "codedBase::updateLibrary()",
309 const fileName libPath = dynCode.libPath();
313 if (libs().findLibrary(libPath))
319 <<
"Using dynamicCode for " << this->description().c_str()
325 this->clearRedirect();
331 void* lib =
loadLibrary(libPath, dynCode.codeName(), context);
341 createLibrary(dynCode, context);
347 oldLibPath_ = libPath;
365 updateLibrary(
name, context_);
369 updateLibrary(
name, dynamicCodeContext(this->codeDict()));
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
A class for handling file names.
Inter-processor communication reduction functions.
std::string str(const bool prefixed=false) const
The digest (40-byte) text representation, optionally with '_' prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static float fileModificationSkew
Time skew (seconds) for file modification checks.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static void waitForFile(const fileName &file, const dictionary &contextDict)
Wait for libPath() file to appear on sub-ranks.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
const word dictName("faMeshDefinition")
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary, otherwise Fatal.
bool store()
Register object with its registry and transfer ownership to the registry.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Ignore writing from objectRegistry::writeObject()
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
void append(const std::string &str)
Add content to SHA1 hashing.
const fileName & name() const noexcept
The dictionary name.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
const dictionary & dict() const noexcept
Return the parent dictionary context.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
static word basename(const fileName &libPath)
Library basename without leading 'lib' or trailing '.so'.
A class for handling words, derived from Foam::string.
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
static void * loadLibrary(const Foam::fileName &libName)
const Time & time() const noexcept
Return time registry.
const word & system() const noexcept
Return system name.
void setCodeContext(const dictionary &dict)
Set code context from a dictionary.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
static void writeEntryIfPresent(Ostream &os, const dictionary &dict, const word &key)
Tools for handling dynamic code compilation.
Encapsulation of dynamic code dictionaries.
void updateLibrary(const word &name, const dynamicCodeContext &context) const
Update library as required, using the given context.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
virtual bool isDict() const noexcept
True if this entry is a dictionary.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Registry of regIOobjects.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
static void checkSecurity(const char *title, const dictionary &)
Check security for creating dynamic code.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Request registration (bool: true)
static void writeCodeDict(Ostream &os, const dictionary &dict)
Write code-dictionary contents.
label startLineNumber() const
Return line number of first token in dictionary.
virtual const dictionary & codeDict() const =0
A keyword and a list of tokens is an 'entry'.
static void barrier(const label communicator, UPstream::Request *req=nullptr)
Impose a synchronisation barrier (optionally non-blocking)
const SHA1 & sha1() const noexcept
The SHA1 calculated from options, libs, include, code, etc.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...