Andrew Makhorin a écrit :
I am trying to run GLPK in multi-thread way, but I discovered, that
there is a problem with memory allocation/deallocation.
I modified the library code:
void *xmalloc(int size) {
return calloc(1, size);
....
}
I am personally using self-made parallel branch-and-bound code, and had
to make equivalent modifications when using POSIX threads.
To make glpk thread-safe you need to provide two platform-specific
routines lib_set_ptr and lib_get_ptr (see src/glplib03.c). By default
these routines store a pointer in the static memory, and currently
only a version for the windows dll is implemented.
I already did such using POSIX threads, using the pthread_key_create and
pthread_setspecific calls. One problem remains though: a thread can not
call glp_delete_prob on a LP that has been allocated by another thread.
Using malloc/free, this is perfectly possible.
Thus, it is quite difficult to maintain a pool of B&B nodes which can be
handled in the same way by all the threads.
--
François Galea
Equipe OPALE - Laboratoire PRiSM
Université de Versailles-Saint Quentin en Yvelines
45 av Etats-Unis F-78035 Versailles CEDEX
Tél. : +33 1 39 25 40 50
_______________________________________________
Help-glpk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-glpk