Go to the documentation of this file.
131 void* 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
174 void 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
209 void 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;
343 context_.setCodeContext(
dict);
349 context_.append(str);
361 "codedBase::updateLibrary()",
373 const fileName libPath = dynCode.libPath();
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_);
A keyword and a list of tokens is an 'entry'.
Type * getObjectPtr(const word &name, const bool recursive=false) const
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
void append(const std::string &str)
Add content to SHA1 hashing.
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Create a bitSet with length n with the specified on locations.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A class for handling words, derived from Foam::string.
A class for handling file names.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
static void writeCodeDict(Ostream &os, const dictionary &dict)
Write code-dictionary contents.
virtual const dictionary & codeDict() const =0
std::string str(const bool prefixed=false) const
The digest (40-byte) text representation, optionally with '_' prefix.
Tools for handling dynamic code compilation.
static word basename(const fileName &libPath)
Library basename without leading 'lib' or trailing '.so'.
Encapsulation of dynamic code dictionaries.
const word dictName("faMeshDefinition")
virtual bool isDict() const noexcept
Return true if this entry is a dictionary.
static void writeEntryIfPresent(Ostream &os, const dictionary &dict, const word &key)
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)
Am I the master process.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dictionary & dict() const noexcept
Return the parent dictionary context.
const fileName & name() const noexcept
The dictionary name.
void setCodeContext(const dictionary &dict)
Set code context from a dictionary.
const SHA1 & sha1() const noexcept
The SHA1 calculated from options, libs, include, code, etc.
Registry of regIOobjects.
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).
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
static void checkSecurity(const char *title, const dictionary &)
Check security for creating dynamic code.
label startLineNumber() const
Return line number of first token in dictionary.
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,...
OBJstream os(runTime.globalPath()/outputName)
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
Inter-processor communication reduction functions.
#define DebugPout
Report an information message using Foam::Pout.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const word & system() const
Return system name.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
void updateLibrary(const word &name, const dynamicCodeContext &context) const
Update library as required, using the given context.
defineTypeNameAndDebug(combustionModel, 0)
unsigned int sleep(const unsigned int sec)
Sleep for the specified number of seconds.
const Time & time() const noexcept
Return time registry.
static int maxFileModificationPolls
Max number of times to poll for file modification changes.