Class Index | Cross Index | Namespace Index |
SoThreader
TODO: put code with cloops into the compiled .cc file
TODO: extend this class to handle shared object file replication
Contained in: global
Derived from:
none
Derived by:
none
#include "general/sothreader.hh"
public function member index: |
|||
SoThreader | (const char* prtstr, int N = 4, bool loadNow = true); | Constructor. | |
~SoThreader | (); | Destructor. | |
void* | getHandle | (); | Get available shared object library handle handle or wait for it. |
void | giveHandle | (void* handle); | Return handle back when done. |
#includeSoThreader lapack("libclapack%d.so", 4, false); //-------------------------------------------------------------------------------- // Get a handle to the CLAPACK library instance void *handle = lapack.getHandle(); //Find a pointer to the function to call int (*dgesvx_) (char *fact, char *trans, integer *n, integer * nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, char *equed, doublereal *r__, doublereal *c__, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal * rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer * iwork, integer *info) = (int (*) (char *fact, char *trans, integer *n, integer * nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, char *equed, doublereal *r__, doublereal *c__, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal * rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer * iwork, integer *info)) dlsym( handle, "dgesvx_" ); // Exit if symbol lookup failed char *error; if ((error = dlerror()) != NULL) { cerr << error << endl; exit(1); } // Do the processing... // CLAPACK library instance is held private to this thread. for (int i = 0; i < 1000; i++) { (*dgesvx_)(&fact, &trans, &n, &nrhs, a, &lda, af, &ldaf, ipiv, &equed, r__, c__, b, &ldb, x, &ldx, &rcond, ferr, berr, work, iwork, &info); inf |= info; } // Release CLAPACK library handle back, which makes it // available for the use in other threads. lapack.giveHandle( handle );
Preload shared object library N times. Prints error message and exits the program if shared object loading fails.
Parameters:
Parameter | Description |
const char* prtstr | Shared object file name template. This has to have a for of "libfoo%d.so", where "%d" will be replaced by the sprintf() function with the decimal numbers in [0-N) range. These object files has to exist in the LD_LIBRARY_PATH for this to work. |
int N | Number of times to preload. |
bool loadNow | "false" means resolve undefined symbols as code from the dynamic library is executed or "true" means resolve all undefined now. Calls exit(1) if this cannot be done. |
Return value:
void*shared object library handle.
Parameters:
Parameter | Description |
void* handle | shared object library handle. |