Loading...
Searching...
No Matches
starpu_helper.h
Go to the documentation of this file.
/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2008-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
*
* StarPU 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.
*
* StarPU 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_HELPER_H__
#define __STARPU_HELPER_H__
#include <stdio.h>
#include <starpu.h>
#ifdef STARPU_HAVE_HWLOC
#include <hwloc.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#define STARPU_MIN(a,b) ((a)<(b)?(a):(b))
#define STARPU_MAX(a,b) ((a)<(b)?(b):(a))
#define STARPU_POISON_PTR ((void *)0xdeadbeef)
extern int _starpu_silent;
char *starpu_getenv(const char *str);
int starpu_get_env_string_var_default(const char *str, const char *strings[], int defvalue);
int starpu_get_env_size_default(const char *str, int defval);
static __starpu_inline int starpu_get_env_number(const char *str)
{
char *strval;
strval = starpu_getenv(str);
if (strval)
{
/* the env variable was actually set */
long int val;
char *pcheck;
val = strtol(strval, &pcheck, 10);
if (*pcheck)
{
fprintf(stderr,"The %s environment variable must contain an integer\n", str);
STARPU_ABORT();
}
/* fprintf(stderr, "ENV %s WAS %d\n", str, val); */
STARPU_ASSERT_MSG(val >= 0, "The value for the environment variable '%s' cannot be negative", str);
return (int)val;
}
else
{
/* there is no such env variable */
/* fprintf("There was no %s ENV\n", str); */
return -1;
}
}
static __starpu_inline int starpu_get_env_number_default(const char *str, int defval)
{
int ret = starpu_get_env_number(str);
if (ret == -1)
ret = defval;
return ret;
}
static __starpu_inline float starpu_get_env_float_default(const char *str, float defval)
{
char *strval;
strval = starpu_getenv(str);
if (strval)
{
/* the env variable was actually set */
float val;
char *pcheck;
val = strtof(strval, &pcheck);
if (*pcheck)
{
fprintf(stderr,"The %s environment variable must contain a float\n", str);
STARPU_ABORT();
}
/* fprintf(stderr, "ENV %s WAS %f\n", str, val); */
return val;
}
else
{
/* there is no such env variable */
/* fprintf("There was no %s ENV\n", str); */
return defval;
}
}
void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t where);
void starpu_execute_on_each_worker_ex(void (*func)(void *), void *arg, uint32_t where, const char *name);
void starpu_execute_on_specific_workers(void (*func)(void*), void *arg, unsigned num_workers, unsigned *workers, const char *name);
double starpu_timing_now(void);
int starpu_data_cpy(starpu_data_handle_t dst_handle, starpu_data_handle_t src_handle, int asynchronous, void (*callback_func)(void*), void *callback_arg);
void starpu_display_bindings(void);
int starpu_get_pu_os_index(unsigned logical_index);
#ifdef STARPU_HAVE_HWLOC
hwloc_topology_t starpu_get_hwloc_topology(void);
#endif
#ifdef __cplusplus
}
#endif
#endif // __STARPU_HELPER_H__
starpu_data_handle_t
struct _starpu_data_state * starpu_data_handle_t
Definition starpu_data.h:44
starpu_execute_on_specific_workers
void starpu_execute_on_specific_workers(void(*func)(void *), void *arg, unsigned num_workers, unsigned *workers, const char *name)
starpu_get_pu_os_index
int starpu_get_pu_os_index(unsigned logical_index)
starpu_get_env_size_default
int starpu_get_env_size_default(const char *str, int defval)
starpu_display_bindings
void starpu_display_bindings(void)
starpu_timing_now
double starpu_timing_now(void)
starpu_execute_on_each_worker_ex
void starpu_execute_on_each_worker_ex(void(*func)(void *), void *arg, uint32_t where, const char *name)
starpu_execute_on_each_worker
void starpu_execute_on_each_worker(void(*func)(void *), void *arg, uint32_t where)
starpu_get_env_string_var_default
int starpu_get_env_string_var_default(const char *str, const char *strings[], int defvalue)
starpu_data_cpy
int starpu_data_cpy(starpu_data_handle_t dst_handle, starpu_data_handle_t src_handle, int asynchronous, void(*callback_func)(void *), void *callback_arg)
starpu_get_hwloc_topology
hwloc_topology_t starpu_get_hwloc_topology(void)
starpu_get_env_number
static __starpu_inline int starpu_get_env_number(const char *str)
Definition starpu_helper.h:75
STARPU_ABORT
#define STARPU_ABORT()
Definition starpu_util.h:246
STARPU_ASSERT_MSG
#define STARPU_ASSERT_MSG(x, msg,...)
Definition starpu_util.h:229
starpu.h