|
@@ -1,7 +1,7 @@
|
|
|
/* StarPU --- Runtime system for heterogeneous multicore architectures.
|
|
|
*
|
|
|
* Copyright (C) 2009-2016 Université de Bordeaux
|
|
|
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015 CNRS
|
|
|
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016 CNRS
|
|
|
* Copyright (C) 2011 Télécom-SudParis
|
|
|
*
|
|
|
* StarPU is free software; you can redistribute it and/or modify
|
|
@@ -658,6 +658,7 @@ void _starpu_perfmodel_realloc(struct starpu_perfmodel *model, int nb)
|
|
|
int i;
|
|
|
|
|
|
STARPU_ASSERT(nb > model->state->ncombs_set);
|
|
|
+ STARPU_ASSERT((size_t) nb < SSIZE_MAX / sizeof(struct starpu_perfmodel_per_arch*));
|
|
|
model->state->per_arch = (struct starpu_perfmodel_per_arch**) realloc(model->state->per_arch, nb*sizeof(struct starpu_perfmodel_per_arch*));
|
|
|
model->state->per_arch_is_set = (int**) realloc(model->state->per_arch_is_set, nb*sizeof(int*));
|
|
|
model->state->nimpls = (int *)realloc(model->state->nimpls, nb*sizeof(int));
|
|
@@ -949,41 +950,34 @@ void _starpu_load_history_based_model(struct starpu_perfmodel *model, unsigned s
|
|
|
|
|
|
unsigned calibrate_flag = _starpu_get_calibrate_flag();
|
|
|
model->benchmarking = calibrate_flag;
|
|
|
+ model->is_loaded = 1;
|
|
|
|
|
|
- /* try to open an existing file and load it */
|
|
|
- int res;
|
|
|
- res = access(path, F_OK);
|
|
|
- if (res == 0)
|
|
|
+ if (calibrate_flag == 2)
|
|
|
{
|
|
|
- if (calibrate_flag == 2)
|
|
|
- {
|
|
|
- /* The user specified that the performance model should
|
|
|
- * be overwritten, so we don't load the existing file !
|
|
|
- * */
|
|
|
- _STARPU_DEBUG("Overwrite existing file\n");
|
|
|
- }
|
|
|
- else
|
|
|
+ /* The user specified that the performance model should
|
|
|
+ * be overwritten, so we don't load the existing file !
|
|
|
+ * */
|
|
|
+ _STARPU_DEBUG("Overwrite existing file\n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* We try to load the file */
|
|
|
+ FILE *f;
|
|
|
+ f = fopen(path, "r");
|
|
|
+ if (f)
|
|
|
{
|
|
|
- /* We load the available file */
|
|
|
- _STARPU_DEBUG("File exists\n");
|
|
|
- FILE *f;
|
|
|
- f = fopen(path, "r");
|
|
|
- STARPU_ASSERT(f);
|
|
|
-
|
|
|
_starpu_frdlock(f);
|
|
|
parse_model_file(f, model, scan_history);
|
|
|
_starpu_frdunlock(f);
|
|
|
-
|
|
|
fclose(f);
|
|
|
+ _STARPU_DEBUG("Performance model file %s for model %s is loaded\n", path, model->symbol);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _STARPU_DEBUG("Performance model file %s does not exist or is not readable\n", path);
|
|
|
}
|
|
|
- _STARPU_DEBUG("Performance model file %s for model %s is loaded\n", path, model->symbol);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _STARPU_DEBUG("Performance model file %s does not exist\n", path);
|
|
|
}
|
|
|
|
|
|
- model->is_loaded = 1;
|
|
|
}
|
|
|
STARPU_PTHREAD_RWLOCK_UNLOCK(&model->state->model_rwlock);
|
|
|
|