Go to the documentation of this file.
54 static inline void writeEntryIfPresent
57 const dictionary&
dict,
69 os.writeEntry(key, toks[0]);
82 writeEntryIfPresent(os,
dict,
"codeInclude");
83 writeEntryIfPresent(os,
dict,
"localCode");
84 writeEntryIfPresent(os,
dict,
"code");
85 writeEntryIfPresent(os,
dict,
"codeOptions");
86 writeEntryIfPresent(os,
dict,
"codeLibs");
92 void* Foam::codedBase::loadLibrary
95 const std::string& funcName,
101 void* handle = libs().open(libPath,
false);
113 const bool ok = libs().loadHook(handle, funcName,
false);
118 <<
"Failed symbol lookup " << funcName.c_str() <<
nl
119 <<
"from " << libPath <<
nl
123 if (!libs().close(libPath,
false))
126 <<
"Failed unloading library " << libPath <<
nl
135 void Foam::codedBase::unloadLibrary
137 const fileName& libPath,
138 const std::string& funcName,
139 const dynamicCodeContext& context
142 void* handle = libs().open(libPath,
false);
152 const bool ok = libs().unloadHook(handle, funcName,
false);
157 <<
"Failed looking up symbol " << funcName <<
nl
158 <<
"from " << libPath <<
nl;
161 if (!libs().close(libPath,
false))
164 <<
"Failed unloading library " << libPath <<
nl
170 void Foam::codedBase::createLibrary
172 dynamicCode& dynCode,
173 const dynamicCodeContext& context
183 if (!dynCode.upToDate(context))
186 dynCode.reset(context);
188 this->prepare(dynCode, context);
190 if (!dynCode.copyOrCreateFiles(
true))
193 <<
"Failed writing files for" <<
nl
194 << dynCode.libRelPath() <<
nl
199 if (!dynCode.wmakeLibso())
202 <<
"Failed wmake " << dynCode.libRelPath() <<
nl
216 const fileName libPath = dynCode.libPath();
219 off_t masterSize = mySize;
231 <<
" have masterSize:" << masterSize
232 <<
" and localSize:" << mySize
235 if (mySize == masterSize)
239 else if (mySize > masterSize)
242 <<
"Excessive size when reading (NFS mounted) library "
243 <<
nl << libPath <<
nl
245 <<
" detected size " << mySize
246 <<
" whereas master size is " << masterSize
248 <<
"If your case is NFS mounted increase"
249 <<
" fileModificationSkew or maxFileModificationPolls;"
250 <<
nl <<
"If your case is not NFS mounted"
251 <<
" (so distributed) set fileModificationSkew"
258 <<
"Local file " << libPath
259 <<
" not of same size (" << mySize
261 << masterSize <<
"). Waiting for "
263 <<
" seconds." <<
endl;
274 if (mySize != masterSize)
277 <<
"Cannot read (NFS mounted) library " <<
nl
280 <<
" detected size " << mySize
281 <<
" whereas master size is " << masterSize
283 <<
"If your case is NFS mounted increase"
284 <<
" fileModificationSkew or maxFileModificationPolls;"
285 <<
nl <<
"If your case is not NFS mounted"
286 <<
" (so distributed) set fileModificationSkew"
293 <<
" after waiting: have masterSize:" << masterSize
294 <<
" and localSize:" << mySize <<
endl;
304 context_.setCodeContext(
dict);
310 context_.append(str);
322 "codedBase::updateLibrary()",
334 const fileName libPath = dynCode.libPath();
338 if (libs().findLibrary(libPath))
344 <<
"Using dynamicCode for " << this->description().c_str()
350 this->clearRedirect();
361 if (!loadLibrary(libPath, dynCode.codeName(), context))
363 createLibrary(dynCode, context);
365 loadLibrary(libPath, dynCode.codeName(), context);
369 oldLibPath_ = libPath;
385 if (context_.valid())
387 updateLibrary(
name, context_);
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.
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.
static void writeCodeDict(Ostream &os, const dictionary &dict)
Write code-dictionary contents.
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'.
const dictionary & dict() const
Return the parent dictionary context.
static float fileModificationSkew
Encapsulation of dynamic code dictionaries.
static int maxFileModificationPolls
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.
void setCodeContext(const dictionary &dict)
Set code context from a dictionary.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const fileName & name() const
The dictionary name.
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 complex &c)
Return string representation of complex.
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.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Inter-processor communication reduction functions.
#define DebugPout
Report an information message using Foam::Pout.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< token > tokenList
List of tokens, used for a IOdictionary entry.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
#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.
const SHA1 & sha1() const
Return SHA1 calculated from options, libs, include, code.
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.