diff --git a/assignments/01/lc_openmp.c b/assignments/01/lc_openmp.c index 85e8c80..10185cf 100644 --- a/assignments/01/lc_openmp.c +++ b/assignments/01/lc_openmp.c @@ -136,6 +136,11 @@ int main(int argc, char **argv) { printf("num correct: %d, out of %d (%.2f%%)\n", num_correct, test_data->rows, (100.0 * num_correct) / test_data->rows); + + free(test_data->buf); + free(test_label->buf); + free(test_data); + free(test_label); } free(w); diff --git a/assignments/01/lc_pthreads.c b/assignments/01/lc_pthreads.c index be8f31e..05a04f7 100644 --- a/assignments/01/lc_pthreads.c +++ b/assignments/01/lc_pthreads.c @@ -35,6 +35,8 @@ int main(int argc, char **argv) { if (data->dimensions < thread_count) thread_count = data->dimensions; + pthread_t *thread_pool = malloc(thread_count * sizeof(pthread_t)); + int *wtf = malloc(thread_count * sizeof(int)); w = calloc(data->dimensions, sizeof(FLOAT)); new_w = calloc(data->dimensions, sizeof(FLOAT)); @@ -49,8 +51,6 @@ int main(int argc, char **argv) { double iter_start_time = monotonic_seconds(); // Spawn N threads - pthread_t *thread_pool = malloc(thread_count * sizeof(pthread_t)); - int *wtf = malloc(thread_count * sizeof(int)); for (int t = 0; t < thread_count; ++t) { wtf[t] = t; pthread_create(&thread_pool[t], NULL, each_thread, &wtf[t]); @@ -99,6 +99,8 @@ int main(int argc, char **argv) { free(labels->buf); free(data); free(labels); + free(thread_pool); + free(wtf); // NOTE: NOT PART OF THE ASSIGNMENT // Perform validation to see how well the model performs on training data @@ -123,6 +125,11 @@ int main(int argc, char **argv) { printf("num correct: %d, out of %d (%.2f%%)\n", num_correct, test_data->rows, (100.0 * num_correct) / test_data->rows); + + free(test_data->buf); + free(test_label->buf); + free(test_data); + free(test_label); } free(w);