diff options
author | Pasha <pasha@member.fsf.org> | 2023-01-27 00:54:07 +0000 |
---|---|---|
committer | Pasha <pasha@member.fsf.org> | 2023-01-27 00:54:07 +0000 |
commit | ef800d4ffafdbde7d7a172ad73bd984b1695c138 (patch) | |
tree | 920cc189130f1e98f252283fce94851443641a6d /glpk-5.0/examples/threads/README | |
parent | ec4ae3c2b5cb0e83fb667f14f832ea94f68ef075 (diff) | |
download | oneapi-master.tar.gz oneapi-master.tar.bz2 |
Diffstat (limited to 'glpk-5.0/examples/threads/README')
-rw-r--r-- | glpk-5.0/examples/threads/README | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/glpk-5.0/examples/threads/README b/glpk-5.0/examples/threads/README new file mode 100644 index 0000000..cb547f0 --- /dev/null +++ b/glpk-5.0/examples/threads/README @@ -0,0 +1,66 @@ +Thread local memory example +=========================== + +The GLPK library, when compiled with default options, uses a separate environment +for each thread that is executed. So each thread is isolated. The only exeption +is error handling. An error in any of the library functions will not only +terminate the active thread but the complete process. + +This can be circumvented by defining an error handling routine with +glp_error_hook(). This directory contains an example demonstrating running a +multithreaded application with error handling. + + +The example code +---------------- + +The program multiseed solves a MathProg model multiple times in separate parallel +threads. Each threads uses a different seed for the MathProg pseudo random number +generator. + +The MathProg model clustering.mod generates 50 randomly distributed "towns". Out +of the towns it selects 3 to be cluster centers and assign the other towns to the +clusters such that the sum of the population weighted euclidian distances between +towns and centers is minimized. + +The solution is written to a Scalable Vector File which can be viewed with a web +browser. + +For demonstration purposes at the end of every third thread the error handling +routine is triggered by calling glp_error(). This results in output like + + 18-00086 Model has been successfully processed + 18-00087 Voluntarily throwing an error in multiseed.c at line 147 + 18-00088 Error detected in file multiseed.c at line 146 + 18-00089 Error caught + +Terminal output is preceeded by numbers indicating the thread index and the +output line. You can pipe it through sort to get a better overiew, e.g. + + multiseed clustering.mod 20 | sort + + +Building and running the example code +------------------------------------- + +On Linux multiseed can be compiled with gcc by calling + + make + +The code can be executed with + + make check + +For compiling the example on 64bit Windows with Microsoft Visual Studio C++ run + + Build_Multiseed.bat + +You may have to adust the variable HOME in the batch file depending on the +installation path of Visual Studio. + +You can run multiseed with + + multiseed <filename> <count> + +Where filename is the path to the model file and count is the number of parallel +threads. |