45 void* Foam::codedBase::loadLibrary
47 const fileName& libPath,
48 const string& globalFuncName,
49 const dictionary& contextDict
57 if (libs().open(libPath,
false))
59 lib = libs().findLibrary(libPath);
67 loaderFunctionType
function =
68 reinterpret_cast<loaderFunctionType
> 70 dlSym(lib, globalFuncName)
82 ) <<
"Failed looking up symbol " << globalFuncName
91 ) <<
"Failed looking up symbol " << globalFuncName <<
nl 95 if (!libs().close(libPath,
false))
100 ) <<
"Failed unloading library " 113 void Foam::codedBase::unloadLibrary
115 const fileName& libPath,
116 const string& globalFuncName,
117 const dictionary& contextDict
127 lib = libs().findLibrary(libPath);
137 loaderFunctionType
function =
138 reinterpret_cast<loaderFunctionType
> 140 dlSym(lib, globalFuncName)
152 ) <<
"Failed looking up symbol " << globalFuncName <<
nl 157 if (!libs().close(libPath,
false))
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>());
292 "codedBase::updateLibrary()",
302 name + context.
sha1().
str(
true),
305 const fileName libPath = dynCode.libPath();
309 if (libs().findLibrary(libPath))
314 Info<<
"Using dynamicCode for " << this->description().c_str()
320 this->clearRedirect();
331 if (!loadLibrary(libPath, dynCode.codeName(), context.
dict()))
333 createLibrary(dynCode, context);
335 loadLibrary(libPath, dynCode.codeName(), context.
dict());
339 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...
off_t fileSize(const fileName &, const bool followLink=true)
Return size of file.
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.
void updateLibrary(const word &name) const
Update library as required.
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.
codedBase()
Construct null.
defineTypeNameAndDebug(combustionModel, 0)
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)
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")
static float fileModificationSkew
std::string str(const bool prefixed=false) const
Return (40-byte) text representation, optionally with '_' prefix.
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.