prototypes for issm_threads.h
More...
Go to the source code of this file.
|
void | LaunchThread (void *function(void *), void *gate, int num_threads) |
|
void | PartitionRange (int *pi0, int *pi1, int num_el, int num_threads, int my_thread) |
|
prototypes for issm_threads.h
Definition in file issm_threads.h.
◆ LaunchThread()
void LaunchThread |
( |
void * |
functionvoid *, |
|
|
void * |
gate, |
|
|
int |
num_threads |
|
) |
| |
Definition at line 25 of file LaunchThread.cpp.
27 #ifdef _MULTITHREADING_
30 pthread_t *threads = NULL;
34 if(num_threads<1)
_error_(
"number of threads must be at least 1");
35 if(num_threads>2000)
_error_(
"number of threads seems to be too high ("<<num_threads<<
">2000)");
38 threads=xNew<pthread_t>(num_threads);
39 handles=xNew<pthread_handle>(num_threads);
41 for(i=0;i<num_threads;i++){
44 handles[i].
num=num_threads;
46 for(i=0;i<num_threads;i++){
48 if(pthread_create(threads+i,NULL,
function,(
void*)(handles+i))){
49 _error_(
"pthread_create error");
52 for(i=0;i<num_threads;i++){
53 if(pthread_join(threads[i],(
void**)&status)){
59 xDelete<pthread_t>(threads);
60 xDelete<pthread_handle>(handles);
68 function((
void*)&handle);
◆ PartitionRange()
void PartitionRange |
( |
int * |
pi0, |
|
|
int * |
pi1, |
|
|
int |
num_el, |
|
|
int |
num_threads, |
|
|
int |
my_thread |
|
) |
| |
Definition at line 13 of file PartitionRange.cpp.
23 step=(int)floor((
double)num_el/(double)num_threads);
24 for(i=0;i<(my_thread+1);i++){
26 if(i==(num_threads-1))i1=num_el;