Explorar o código

Fix atomicity of performance model update

Samuel Thibault %!s(int64=13) %!d(string=hai) anos
pai
achega
31c7516bf0
Modificáronse 1 ficheiros con 6 adicións e 3 borrados
  1. 6 3
      src/core/perfmodel/perfmodel_history.c

+ 6 - 3
src/core/perfmodel/perfmodel_history.c

@@ -966,10 +966,11 @@ double _starpu_non_linear_regression_based_job_expected_perf(struct starpu_perfm
 	{
 		uint32_t key = _starpu_compute_buffers_footprint(model, arch, nimpl, j);
 		struct starpu_per_arch_perfmodel *per_arch_model = &model->per_arch[arch][nimpl];
-		struct starpu_htbl32_node *history = per_arch_model->history;
+		struct starpu_htbl32_node *history;
 		struct starpu_history_entry *entry;
 
 		_STARPU_PTHREAD_RWLOCK_RDLOCK(&model->model_rwlock);
+		history = per_arch_model->history;
 		entry = (struct starpu_history_entry *) _starpu_htbl_search_32(history, key);
 		_STARPU_PTHREAD_RWLOCK_UNLOCK(&model->model_rwlock);
 
@@ -997,11 +998,13 @@ double _starpu_history_based_job_expected_perf(struct starpu_perfmodel *model, e
 
 	per_arch_model = &model->per_arch[arch][nimpl];
 
+	_STARPU_PTHREAD_RWLOCK_RDLOCK(&model->model_rwlock);
 	history = per_arch_model->history;
-	if (!history)
+	if (!history) {
+		_STARPU_PTHREAD_RWLOCK_UNLOCK(&model->model_rwlock);
 		return NAN;
+	}
 
-	_STARPU_PTHREAD_RWLOCK_RDLOCK(&model->model_rwlock);
 	entry = (struct starpu_history_entry *) _starpu_htbl_search_32(history, key);
 	_STARPU_PTHREAD_RWLOCK_UNLOCK(&model->model_rwlock);