Browse Source

free topology tree + fix small bug of exec_paralle_code

Andra Hugo 11 years ago
parent
commit
a0c9760232
3 changed files with 7 additions and 11 deletions
  1. 4 8
      examples/sched_ctx/parallel_code.c
  2. 2 2
      src/core/sched_ctx.c
  3. 1 1
      src/core/workers.c

+ 4 - 8
examples/sched_ctx/parallel_code.c

@@ -36,17 +36,13 @@ int parallel_code(int sched_ctx)
 	starpu_sched_ctx_get_available_cpuids(sched_ctx, &cpuids, &ncpuids);
 
 //	printf("execute task of %d threads \n", ncpuids);
-	omp_set_nested(1);
-#pragma omp parallel num_threads(1)
-	{
 #pragma omp parallel num_threads(ncpuids)
-		{
-			starpu_sched_ctx_bind_current_thread_to_cpuid(cpuids[omp_get_thread_num()]);
+	{
+		starpu_sched_ctx_bind_current_thread_to_cpuid(cpuids[omp_get_thread_num()]);
 // 			printf("cpu = %d ctx%d nth = %d\n", sched_getcpu(), sched_ctx, omp_get_num_threads());
 #pragma omp for
-			for(i = 0; i < NTASKS; i++)
-				t++;
-		}
+		for(i = 0; i < NTASKS; i++)
+			t++;
 	}
 	free(cpuids);
 	return t;

+ 2 - 2
src/core/sched_ctx.c

@@ -1646,7 +1646,7 @@ void* starpu_sched_ctx_exec_parallel_code(void* (*func)(void*), void* param, uns
 {
 	int *workerids;
 	int nworkers = starpu_sched_ctx_get_workers_list(sched_ctx_id, &workerids);
-	_starpu_sched_ctx_get_workers_to_sleep(sched_ctx_id, workerids, nworkers, -1);
+	_starpu_sched_ctx_get_workers_to_sleep(sched_ctx_id, workerids, nworkers, workerids[nworkers-1]);
 
 	/* bind current thread on all workers of the context */
 	_starpu_sched_ctx_bind_thread_to_ctx_cpus(sched_ctx_id);
@@ -1655,7 +1655,7 @@ void* starpu_sched_ctx_exec_parallel_code(void* (*func)(void*), void* param, uns
 	void* ret = func(param);
 
 	/* wake up starpu workers */
-	_starpu_sched_ctx_wake_up_workers(sched_ctx_id, -1);
+	_starpu_sched_ctx_wake_up_workers(sched_ctx_id, workerids[nworkers-1]);
 
 	return ret;
 }

+ 1 - 1
src/core/workers.c

@@ -1320,7 +1320,7 @@ void starpu_shutdown(void)
 	_starpu_delete_all_sched_ctxs();
 
 	_starpu_disk_unregister();
-
+	starpu_tree_free(config.topology.tree);
 	_starpu_destroy_topology(&config);
 #ifdef STARPU_USE_FXT
 	_starpu_stop_fxt_profiling();