Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions SRC/pcmemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static LU_stack_t stack;
static int_t no_expand;
static int_t ndim;
static LU_space_t whichspace; /* 0 - system malloc'd; 1 - user provided */
static int_t nwork_users; /* # threads holding work arrays at the TAIL */

/* Macros to manipulate stack */
#define StackFull(x) ( x + stack.used >= stack.size )
Expand Down Expand Up @@ -93,6 +94,7 @@ void pcgstrf_SetupSpace(void *work, int_t lwork)
stack.top1 = 0;
stack.top2 = lwork;
stack.array = (void *) work;
nwork_users = 0;
}
#if ( MACH==PTHREAD )
pthread_mutex_init ( &stack.lock, NULL);
Expand Down Expand Up @@ -386,6 +388,7 @@ pcgstrf_MemInit(int_t n, int_t annz, superlumt_options_t *superlumt_options,
whichspace = USER;
stack.size = lwork;
stack.top2 = lwork;
nwork_users = 0;
}

lsub = cexpanders[LSUB].mem = Lstore->rowind;
Expand Down Expand Up @@ -484,6 +487,20 @@ pcgstrf_WorkInit(int_t n, int_t panel_size, int_t **iworkptr, complex **dworkptr
printf("malloc fails for local dworkptr[] ... dsize " IFMT "\n", dsize);
return (isize + dsize + n);
}

if ( whichspace == USER ) {
#if ( MACH==PTHREAD ) /* Use pthread ... */
pthread_mutex_lock( &stack.lock );
#elif ( MACH==OPENMP ) /* Use openMP ... */
#pragma omp critical ( STACK_LOCK )
#endif
{
++nwork_users;
}
#if ( MACH==PTHREAD ) /* Use pthread ... */
pthread_mutex_unlock( &stack.lock );
#endif
}

return 0;
}
Expand Down Expand Up @@ -521,8 +538,12 @@ void pcgstrf_WorkFree(int_t *iwork, complex *dwork, GlobalLU_t *Glu)
#pragma omp critical ( STACK_LOCK )
#endif
{
stack.used -= (stack.size - stack.top2);
stack.top2 = stack.size;
/* The TAIL holds the work arrays of all threads, so it can only
be released after the last thread is done with its own. */
if ( --nwork_users == 0 ) {
stack.used -= (stack.size - stack.top2);
stack.top2 = stack.size;
}

/* pcgstrf_StackCompress(Glu); */
}
Expand Down
25 changes: 23 additions & 2 deletions SRC/pdmemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static LU_stack_t stack;
static int_t no_expand;
static int_t ndim;
static LU_space_t whichspace; /* 0 - system malloc'd; 1 - user provided */
static int_t nwork_users; /* # threads holding work arrays at the TAIL */

/* Macros to manipulate stack */
#define StackFull(x) ( x + stack.used >= stack.size )
Expand Down Expand Up @@ -93,6 +94,7 @@ void pdgstrf_SetupSpace(void *work, int_t lwork)
stack.top1 = 0;
stack.top2 = lwork;
stack.array = (void *) work;
nwork_users = 0;
}
#if ( MACH==PTHREAD )
pthread_mutex_init ( &stack.lock, NULL);
Expand Down Expand Up @@ -386,6 +388,7 @@ pdgstrf_MemInit(int_t n, int_t annz, superlumt_options_t *superlumt_options,
whichspace = USER;
stack.size = lwork;
stack.top2 = lwork;
nwork_users = 0;
}

lsub = dexpanders[LSUB].mem = Lstore->rowind;
Expand Down Expand Up @@ -484,6 +487,20 @@ pdgstrf_WorkInit(int_t n, int_t panel_size, int_t **iworkptr, double **dworkptr)
printf("malloc fails for local dworkptr[] ... dsize " IFMT "\n", dsize);
return (isize + dsize + n);
}

if ( whichspace == USER ) {
#if ( MACH==PTHREAD ) /* Use pthread ... */
pthread_mutex_lock( &stack.lock );
#elif ( MACH==OPENMP ) /* Use openMP ... */
#pragma omp critical ( STACK_LOCK )
#endif
{
++nwork_users;
}
#if ( MACH==PTHREAD ) /* Use pthread ... */
pthread_mutex_unlock( &stack.lock );
#endif
}

return 0;
}
Expand Down Expand Up @@ -521,8 +538,12 @@ void pdgstrf_WorkFree(int_t *iwork, double *dwork, GlobalLU_t *Glu)
#pragma omp critical ( STACK_LOCK )
#endif
{
stack.used -= (stack.size - stack.top2);
stack.top2 = stack.size;
/* The TAIL holds the work arrays of all threads, so it can only
be released after the last thread is done with its own. */
if ( --nwork_users == 0 ) {
stack.used -= (stack.size - stack.top2);
stack.top2 = stack.size;
}

/* pdgstrf_StackCompress(Glu); */
}
Expand Down
25 changes: 23 additions & 2 deletions SRC/psmemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static LU_stack_t stack;
static int_t no_expand;
static int_t ndim;
static LU_space_t whichspace; /* 0 - system malloc'd; 1 - user provided */
static int_t nwork_users; /* # threads holding work arrays at the TAIL */

/* Macros to manipulate stack */
#define StackFull(x) ( x + stack.used >= stack.size )
Expand Down Expand Up @@ -93,6 +94,7 @@ void psgstrf_SetupSpace(void *work, int_t lwork)
stack.top1 = 0;
stack.top2 = lwork;
stack.array = (void *) work;
nwork_users = 0;
}
#if ( MACH==PTHREAD )
pthread_mutex_init ( &stack.lock, NULL);
Expand Down Expand Up @@ -386,6 +388,7 @@ psgstrf_MemInit(int_t n, int_t annz, superlumt_options_t *superlumt_options,
whichspace = USER;
stack.size = lwork;
stack.top2 = lwork;
nwork_users = 0;
}

lsub = sexpanders[LSUB].mem = Lstore->rowind;
Expand Down Expand Up @@ -484,6 +487,20 @@ psgstrf_WorkInit(int_t n, int_t panel_size, int_t **iworkptr, float **dworkptr)
printf("malloc fails for local dworkptr[] ... dsize " IFMT "\n", dsize);
return (isize + dsize + n);
}

if ( whichspace == USER ) {
#if ( MACH==PTHREAD ) /* Use pthread ... */
pthread_mutex_lock( &stack.lock );
#elif ( MACH==OPENMP ) /* Use openMP ... */
#pragma omp critical ( STACK_LOCK )
#endif
{
++nwork_users;
}
#if ( MACH==PTHREAD ) /* Use pthread ... */
pthread_mutex_unlock( &stack.lock );
#endif
}

return 0;
}
Expand Down Expand Up @@ -521,8 +538,12 @@ void psgstrf_WorkFree(int_t *iwork, float *dwork, GlobalLU_t *Glu)
#pragma omp critical ( STACK_LOCK )
#endif
{
stack.used -= (stack.size - stack.top2);
stack.top2 = stack.size;
/* The TAIL holds the work arrays of all threads, so it can only
be released after the last thread is done with its own. */
if ( --nwork_users == 0 ) {
stack.used -= (stack.size - stack.top2);
stack.top2 = stack.size;
}

/* psgstrf_StackCompress(Glu); */
}
Expand Down
25 changes: 23 additions & 2 deletions SRC/pzmemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static LU_stack_t stack;
static int_t no_expand;
static int_t ndim;
static LU_space_t whichspace; /* 0 - system malloc'd; 1 - user provided */
static int_t nwork_users; /* # threads holding work arrays at the TAIL */

/* Macros to manipulate stack */
#define StackFull(x) ( x + stack.used >= stack.size )
Expand Down Expand Up @@ -93,6 +94,7 @@ void pzgstrf_SetupSpace(void *work, int_t lwork)
stack.top1 = 0;
stack.top2 = lwork;
stack.array = (void *) work;
nwork_users = 0;
}
#if ( MACH==PTHREAD )
pthread_mutex_init ( &stack.lock, NULL);
Expand Down Expand Up @@ -386,6 +388,7 @@ pzgstrf_MemInit(int_t n, int_t annz, superlumt_options_t *superlumt_options,
whichspace = USER;
stack.size = lwork;
stack.top2 = lwork;
nwork_users = 0;
}

lsub = zexpanders[LSUB].mem = Lstore->rowind;
Expand Down Expand Up @@ -484,6 +487,20 @@ pzgstrf_WorkInit(int_t n, int_t panel_size, int_t **iworkptr, doublecomplex **dw
printf("malloc fails for local dworkptr[] ... dsize " IFMT "\n", dsize);
return (isize + dsize + n);
}

if ( whichspace == USER ) {
#if ( MACH==PTHREAD ) /* Use pthread ... */
pthread_mutex_lock( &stack.lock );
#elif ( MACH==OPENMP ) /* Use openMP ... */
#pragma omp critical ( STACK_LOCK )
#endif
{
++nwork_users;
}
#if ( MACH==PTHREAD ) /* Use pthread ... */
pthread_mutex_unlock( &stack.lock );
#endif
}

return 0;
}
Expand Down Expand Up @@ -521,8 +538,12 @@ void pzgstrf_WorkFree(int_t *iwork, doublecomplex *dwork, GlobalLU_t *Glu)
#pragma omp critical ( STACK_LOCK )
#endif
{
stack.used -= (stack.size - stack.top2);
stack.top2 = stack.size;
/* The TAIL holds the work arrays of all threads, so it can only
be released after the last thread is done with its own. */
if ( --nwork_users == 0 ) {
stack.used -= (stack.size - stack.top2);
stack.top2 = stack.size;
}

/* pzgstrf_StackCompress(Glu); */
}
Expand Down
Loading