123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- /*
- * StarPU
- * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
- #ifndef __STARPU_PERFMODEL_H__
- #define __STARPU_PERFMODEL_H__
- #include <stdio.h>
- #ifndef __MINGW32__
- #include <pthread.h>
- #else
- #include <windows.h>
- #undef interface
- #endif
- #include <starpu.h>
- #include <starpu_config.h>
- #include <starpu_task.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- struct starpu_htbl32_node_s;
- struct starpu_history_list_t;
- struct starpu_buffer_descr_t;
- /*
- it is possible that we have multiple versions of the same kind of workers,
- for instance multiple GPUs or even different CPUs within the same machine
- so we do not use the archtype enum type directly for performance models
- */
- enum starpu_perf_archtype {
- STARPU_CPU_DEFAULT = 0,
- STARPU_CUDA_DEFAULT = 1,
- STARPU_OPENCL_DEFAULT = STARPU_CUDA_DEFAULT + STARPU_MAXCUDADEVS,
- /* STARPU_OPENCL_DEFAULT + devid */
- STARPU_GORDON_DEFAULT = STARPU_OPENCL_DEFAULT + STARPU_MAXOPENCLDEVS
- };
- #define STARPU_NARCH_VARIATIONS (STARPU_GORDON_DEFAULT+1)
- struct starpu_regression_model_t {
- /* sum of ln(measured) */
- double sumlny;
- /* sum of ln(size) */
- double sumlnx;
- double sumlnx2;
- /* sum of ln(size) ln(measured) */
- double sumlnxlny;
- /* y = alpha size ^ beta */
- double alpha;
- double beta;
- /* y = a size ^b + c */
- double a, b, c;
- unsigned valid;
- unsigned nsample;
- };
- struct starpu_per_arch_perfmodel_t {
- double (*cost_model)(struct starpu_buffer_descr_t *t);
- double alpha;
- struct starpu_htbl32_node_s *history;
- struct starpu_history_list_t *list;
- struct starpu_regression_model_t regression;
- #ifdef STARPU_MODEL_DEBUG
- FILE *debug_file;
- #endif
- };
- typedef enum {STARPU_PER_ARCH, STARPU_COMMON, STARPU_HISTORY_BASED, STARPU_REGRESSION_BASED} starpu_perfmodel_type;
- struct starpu_perfmodel_t {
- /* which model is used for that task ? */
- starpu_perfmodel_type type;
- /* single cost model */
- double (*cost_model)(struct starpu_buffer_descr_t *);
- /* per-architecture model */
- struct starpu_per_arch_perfmodel_t per_arch[STARPU_NARCH_VARIATIONS];
-
- const char *symbol;
- enum {
- STARPU_PERFMODEL_NOT_LOADED,
- STARPU_PERFMODEL_LOADING,
- STARPU_PERFMODEL_LOADED
- } is_loaded;
- unsigned benchmarking;
- #ifndef __MINGW32__
- pthread_rwlock_t model_rwlock;
- #else
- HANDLE model_rwlock;
- #endif
- };
- /* This function is intended to be used by external tools that should read the
- * performance model files */
- int starpu_load_history_debug(const char *symbol, struct starpu_perfmodel_t *model);
- void starpu_perfmodel_debugfilepath(struct starpu_perfmodel_t *model,
- enum starpu_perf_archtype arch, char *path, size_t maxlen);
- void starpu_perfmodel_get_arch_name(enum starpu_perf_archtype arch,
- char *archname, size_t maxlen);
- void starpu_force_bus_sampling(void);
- #ifdef __cplusplus
- }
- #endif
- #endif // __STARPU_PERFMODEL_H__
|