131void* Foam::codedBase::loadLibrary
134 const std::string& funcName,
140 void* handle = libs().open(libPath,
false);
152 const bool ok = libs().loadHook(handle, funcName,
false);
157 <<
"Failed symbol lookup " << funcName.c_str() <<
nl
158 <<
"from " << libPath <<
nl
162 if (!libs().close(libPath,
false))
165 <<
"Failed unloading library " << libPath <<
nl
174void Foam::codedBase::unloadLibrary
176 const fileName& libPath,
177 const std::string& funcName,
178 const dynamicCodeContext& context
181 void* handle = libs().open(libPath,
false);
191 const bool ok = libs().unloadHook(handle, funcName,
false);
196 <<
"Failed looking up symbol " << funcName <<
nl
197 <<
"from " << libPath <<
nl;
200 if (!libs().close(libPath,
false))
203 <<
"Failed unloading library " << libPath <<
nl
209void Foam::codedBase::createLibrary
211 dynamicCode& dynCode,
212 const dynamicCodeContext& context
222 if (!dynCode.upToDate(context))
225 dynCode.reset(context);
227 this->prepare(dynCode, context);
229 if (!dynCode.copyOrCreateFiles(
true))
232 <<
"Failed writing files for" <<
nl
233 << dynCode.libRelPath() <<
nl
238 if (!dynCode.wmakeLibso())
241 <<
"Failed wmake " << dynCode.libRelPath() <<
nl
255 const fileName libPath = dynCode.libPath();
258 off_t masterSize = mySize;
270 <<
" have masterSize:" << masterSize
271 <<
" and localSize:" << mySize
274 if (mySize == masterSize)
278 else if (mySize > masterSize)
281 <<
"Excessive size when reading (NFS mounted) library "
282 <<
nl << libPath <<
nl
284 <<
" detected size " << mySize
285 <<
" whereas master size is " << masterSize
287 <<
"If your case is NFS mounted increase"
288 <<
" fileModificationSkew or maxFileModificationPolls;"
289 <<
nl <<
"If your case is not NFS mounted"
290 <<
" (so distributed) set fileModificationSkew"
297 <<
"Local file " << libPath
298 <<
" not of same size (" << mySize
300 << masterSize <<
"). Waiting for "
302 <<
" seconds." <<
endl;
313 if (mySize != masterSize)
316 <<
"Cannot read (NFS mounted) library " <<
nl
319 <<
" detected size " << mySize
320 <<
" whereas master size is " << masterSize
322 <<
"If your case is NFS mounted increase"
323 <<
" fileModificationSkew or maxFileModificationPolls;"
324 <<
nl <<
"If your case is not NFS mounted"
325 <<
" (so distributed) set fileModificationSkew"
332 <<
" after waiting: have masterSize:" << masterSize
333 <<
" and localSize:" << mySize <<
endl;
335 reduce(create, orOp<bool>());
343 context_.setCodeContext(
dict);
349 context_.append(str);
361 "codedBase::updateLibrary()",
377 if (libs().findLibrary(libPath))
383 <<
"Using dynamicCode for " << this->description().c_str()
389 this->clearRedirect();
400 if (!loadLibrary(libPath, dynCode.
codeName(), context))
402 createLibrary(dynCode, context);
404 loadLibrary(libPath, dynCode.
codeName(), context);
408 oldLibPath_ = libPath;
424 if (context_.valid())
426 updateLibrary(
name, context_);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Inter-processor communication reduction functions.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static float fileModificationSkew
Time skew (seconds) for file modification checks.
static int maxFileModificationPolls
Max number of times to poll for file modification changes.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
std::string str(const bool prefixed=false) const
The digest (40-byte) text representation, optionally with '_' prefix.
const word & system() const
Return system name.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Base class for function objects and boundary conditions using dynamic code that provides methods for ...
void updateLibrary(const word &name, const dynamicCodeContext &context) const
Update library as required, using the given context.
void setCodeContext(const dictionary &dict)
Set code context from a dictionary.
virtual const dictionary & codeDict() const =0
static void writeCodeDict(Ostream &os, const dictionary &dict)
Write code-dictionary contents.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const fileName & name() const noexcept
The dictionary name.
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
label startLineNumber() const
Return line number of first token in dictionary.
static word basename(const fileName &libPath)
Library basename without leading 'lib' or trailing '.so'.
Encapsulation of dynamic code dictionaries.
const SHA1 & sha1() const noexcept
The SHA1 calculated from options, libs, include, code, etc.
const dictionary & dict() const noexcept
Return the parent dictionary context.
Tools for handling dynamic code compilation.
static void checkSecurity(const char *title, const dictionary &)
Check security for creating dynamic code.
fileName libPath() const
Library path for specified code name.
const word & codeName() const
Return the code-name.
A keyword and a list of tokens is an 'entry'.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
virtual bool isDict() const noexcept
Return true if this entry is a dictionary.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
A class for handling file names.
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
Type * getObjectPtr(const word &name, const bool recursive=false) const
int myProcNo() const noexcept
Return processor number.
splitCell * master() const
bool append() const noexcept
True if output format uses an append mode.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
const word dictName("faMeshDefinition")
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
#define DebugPout
Report an information message using Foam::Pout.
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Create a bitSet with length n with the specified on locations.
static void writeEntryIfPresent(Ostream &os, const dictionary &dict, const word &key)
unsigned int sleep(const unsigned int sec)
Sleep for the specified number of seconds.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)