Skip to content

Commit 1d8b408

Browse files
committed
memory leak: RRR not freed in subset case
1 parent fa2e43e commit 1d8b408

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

INCLUDE/counter.h

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ counter_t *PMR_create_counter(int init_value);
5757
int PMR_get_counter_value(counter_t *counter);
5858
int PMR_set_counter_value(counter_t *counter, int value);
5959
int PMR_decrement_counter(counter_t *counter, int amount);
60+
int PMR_increment_counter(counter_t *counter, int amount);
6061
void PMR_destroy_counter(counter_t *counter);
6162

6263
#endif

SRC/counter.c

+27
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,30 @@ int PMR_decrement_counter(counter_t *counter, int amount)
151151

152152
return(value);
153153
}
154+
155+
156+
157+
158+
int PMR_increment_counter(counter_t *counter, int amount)
159+
{
160+
int value, info;
161+
162+
#ifdef NOSPINLOCKS
163+
info = pthread_mutex_lock(&counter->lock);
164+
#else
165+
info = pthread_spin_lock(&counter->lock);
166+
#endif
167+
assert(info == 0);
168+
169+
counter->value += amount;
170+
value = counter->value;
171+
172+
#ifdef NOSPINLOCKS
173+
info = pthread_mutex_unlock(&counter->lock);
174+
#else
175+
info = pthread_spin_unlock(&counter->lock);
176+
#endif
177+
assert(info == 0);
178+
179+
return(value);
180+
}

SRC/process_c_task.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ int create_subtasks(cluster_t *cl, int tid, proc_t *procinfo,
697697
int pid = procinfo->pid;
698698
int nproc = procinfo->nproc;
699699
int nthreads = procinfo->nthreads;
700+
bool proc_involved=true;
700701

701702
double *restrict Wgap = Wstruct->Wgap;
702703
double *restrict Wshifted = Wstruct->Wshifted;
@@ -707,7 +708,7 @@ int create_subtasks(cluster_t *cl, int tid, proc_t *procinfo,
707708
int *restrict Zindex = Zstruct->Zindex;
708709

709710
/* others */
710-
int i, l;
711+
int i, l, k;
711712
int max_size;
712713
task_t *task;
713714
bool task_inserted;
@@ -754,6 +755,21 @@ int create_subtasks(cluster_t *cl, int tid, proc_t *procinfo,
754755
if (i==cl_end || sn_size>=max_size ||
755756
Wgap[i+1] < MIN_RELGAP*fabs(Wshifted[i+1])) {
756757

758+
/* Check if process involved in s-task */
759+
proc_involved = false;
760+
for (k=sn_first; k<=sn_last; k++) {
761+
if (iproc[k] == pid) {
762+
proc_involved = true;
763+
break;
764+
}
765+
}
766+
if (proc_involved == false) {
767+
task_inserted = true;
768+
new_first = i + 1;
769+
continue;
770+
}
771+
772+
/* Insert task as process is involved */
757773
if (sn_first == cl_begin) {
758774
lgap = cl->lgap;
759775
} else {

0 commit comments

Comments
 (0)