45 void* Foam::codedBase::loadLibrary
47 const fileName& libPath,
48 const string& globalFuncName,
49 const dictionary& contextDict
67 loaderFunctionType
function =
68 reinterpret_cast<loaderFunctionType
> 70 dlSym(lib, globalFuncName)
82 ) <<
"Failed looking up symbol " << globalFuncName
91 ) <<
"Failed looking up symbol " << globalFuncName <<
nl 100 ) <<
"Failed unloading library " 113 void Foam::codedBase::unloadLibrary
115 const fileName& libPath,
116 const string& globalFuncName,
117 const dictionary& contextDict
137 loaderFunctionType
function =
138 reinterpret_cast<loaderFunctionType
> 140 dlSym(lib, globalFuncName)
152 ) <<
"Failed looking up symbol " << globalFuncName <<
nl 162 ) <<
"Failed unloading library " << libPath
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))
195 ) <<
"Failed writing files for" <<
nl 196 << dynCode.libRelPath() <<
nl 201 if (!dynCode.wmakeLibso())
206 ) <<
"Failed wmake " << dynCode.libRelPath() <<
nl 220 const fileName libPath = dynCode.libPath();
223 off_t masterSize = mySize;
229 <<
" have masterSize:" << masterSize
230 <<
" and localSize:" << mySize
235 if (mySize < masterSize)
239 Pout<<
"Local file " << libPath
240 <<
" not of same size (" << mySize
242 << masterSize <<
"). Waiting for " 244 <<
" seconds." <<
endl;
251 if (mySize < masterSize)
256 ) <<
"Cannot read (NFS mounted) library " <<
nl 259 <<
" detected size " << mySize
260 <<
" whereas master size is " << masterSize
262 <<
"If your case is not NFS mounted" 263 <<
" (so distributed) set fileModificationSkew" 272 <<
" after waiting: have masterSize:" << masterSize
273 <<
" and localSize:" << mySize
277 reduce(create, orOp<bool>());
290 "codedBase::updateLibrary()",
300 name + context.
sha1().
str(
true),
303 const fileName libPath = dynCode.libPath();
312 Info<<
"Using dynamicCode for " << this->description().c_str()
318 this->clearRedirect();
329 if (!loadLibrary(libPath, dynCode.codeName(), context.
dict()))
331 createLibrary(dynCode, context);
333 if (!loadLibrary(libPath, dynCode.codeName(), context.
dict()))
341 oldLibPath_ = libPath;
A class for handling file names.
Inter-processor communication reduction functions.
const SHA1Digest & sha1() const
Return SHA1 digest calculated from include, options, code.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
const dictionary & dict() const
Return the parent dictionary context.
dlLibraryTable libs
Table of loaded dynamic libraries.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
const fileName & name() const
Return the dictionary name.
A class for handling words, derived from string.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
bool close(const fileName &name, const bool verbose=true)
Close the named library, optionally with warnings if problems occur.
codedBase()
Construct null.
defineTypeNameAndDebug(combustionModel, 0)
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
static word libraryBaseName(const fileName &libPath)
Return the library basename without leading 'lib' or trailing '.so'.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void updateLibrary() const
Update library as required.
word name(const complex &)
Return a string representation of a complex.
Tools for handling dynamic code compilation.
Encapsulation of dynamic code dictionaries.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
prefixOSstream Pout(cout, "Pout")
void * findLibrary(const fileName &libName)
Find the handle of the named library.
static float fileModificationSkew
std::string str(const bool prefixed=false) const
Return (40-byte) text representation, optionally with '_' prefix.
off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return size of file.
static void checkSecurity(const char *title, const dictionary &)
Check security for creating dynamic code.
unsigned int sleep(const unsigned int)
Sleep for the specified number of seconds.
virtual ~codedBase()
Destructor.
void * dlSym(void *handle, const std::string &symbol)
Lookup a symbol in a dlopened library using handle to library.
bool dlSymFound(void *handle, const std::string &symbol)
Report if symbol in a dlopened library could be found.
label startLineNumber() const
Return line number of first token in dictionary.