Explorar el Código

Avoid allocating before we checked whether starpu_init shall return ENODEV or not

Samuel Thibault hace 4 años
padre
commit
746ad41619
Se han modificado 2 ficheros con 8 adiciones y 3 borrados
  1. 3 0
      src/core/workers.c
  2. 5 3
      src/datawizard/interfaces/data_interface.c

+ 3 - 0
src/core/workers.c

@@ -1557,6 +1557,9 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
 
 	_starpu_load_bus_performance_files();
 
+	/* Note: nothing before here should be allocating anything, in case we
+	 * actually return ENODEV here */
+
 	/* Depending on whether we are a MP sink or not, we must build the
 	 * topology with MP nodes or not. */
 	ret = _starpu_build_topology(&_starpu_config, is_a_sink);

+ 5 - 3
src/datawizard/interfaces/data_interface.c

@@ -53,8 +53,6 @@ static void _starpu_data_unregister(starpu_data_handle_t handle, unsigned cohere
 void _starpu_data_interface_init(void)
 {
 	_starpu_spin_init(&registered_handles_lock);
-	_id_to_ops_array_size = 20;
-	_STARPU_MALLOC(_id_to_ops_array, _id_to_ops_array_size * sizeof(struct starpu_data_interface_ops *));
 
 	/* Just for testing purpose */
 	if (starpu_get_env_number_default("STARPU_GLOBAL_ARBITER", 0) > 0)
@@ -573,7 +571,11 @@ void starpu_data_register(starpu_data_handle_t *handleptr, int home_node,
 	{
 		if ((unsigned)ops->interfaceid > _id_to_ops_array_size)
 		{
-			_id_to_ops_array_size *= 2;
+			if (!_id_to_ops_array_size) {
+				_id_to_ops_array_size = 16;
+			} else {
+				_id_to_ops_array_size *= 2;
+			}
 			_STARPU_REALLOC(_id_to_ops_array, _id_to_ops_array_size * sizeof(struct starpu_data_interface_ops *));
 		}
 		_id_to_ops_array[ops->interfaceid-STARPU_MAX_INTERFACE_ID] = ops;