|
@@ -84,15 +84,22 @@ void _starpu_perfmodel_malloc_per_arch_is_set(struct starpu_perfmodel *model, in
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device* devices)
|
|
|
+void _starpu_perfmodel_arch_combs_realloc(int new_nb_arch_combs)
|
|
|
{
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&arch_combs_mutex);
|
|
|
+ nb_arch_combs = new_nb_arch_combs;
|
|
|
+ arch_combs = (struct starpu_perfmodel_arch**) realloc(arch_combs, nb_arch_combs*sizeof(struct starpu_perfmodel_arch*));
|
|
|
+ STARPU_PTHREAD_MUTEX_UNLOCK(&arch_combs_mutex);
|
|
|
+}
|
|
|
+
|
|
|
+int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device* devices)
|
|
|
+{
|
|
|
if (current_arch_comb >= nb_arch_combs)
|
|
|
{
|
|
|
// We need to allocate more arch_combs
|
|
|
- nb_arch_combs += 10;
|
|
|
- arch_combs = (struct starpu_perfmodel_arch**) realloc(arch_combs, nb_arch_combs*sizeof(struct starpu_perfmodel_arch*));
|
|
|
+ _starpu_perfmodel_arch_combs_realloc(nb_arch_combs + 10);
|
|
|
}
|
|
|
+ STARPU_PTHREAD_MUTEX_LOCK(&arch_combs_mutex);
|
|
|
arch_combs[current_arch_comb] = (struct starpu_perfmodel_arch*)malloc(sizeof(struct starpu_perfmodel_arch));
|
|
|
arch_combs[current_arch_comb]->devices = (struct starpu_perfmodel_device*)malloc(ndevices*sizeof(struct starpu_perfmodel_device));
|
|
|
arch_combs[current_arch_comb]->ndevices = ndevices;
|
|
@@ -510,11 +517,7 @@ static void parse_model_file(FILE *f, struct starpu_perfmodel *model, unsigned s
|
|
|
if (ncombs > nb_arch_combs)
|
|
|
{
|
|
|
// The model has more combs than the original number of arch_combs, we need to reallocate
|
|
|
- STARPU_PTHREAD_MUTEX_LOCK(&arch_combs_mutex);
|
|
|
- nb_arch_combs = ncombs;
|
|
|
- arch_combs = (struct starpu_perfmodel_arch**) realloc(arch_combs, nb_arch_combs*sizeof(struct starpu_perfmodel_arch*));
|
|
|
- STARPU_PTHREAD_MUTEX_UNLOCK(&arch_combs_mutex);
|
|
|
-
|
|
|
+ _starpu_perfmodel_arch_combs_realloc(ncombs);
|
|
|
_starpu_perfmodel_realloc(model, nb_arch_combs);
|
|
|
}
|
|
|
|