Loading...
Searching...
No Matches
memory_nodes.h
Go to the documentation of this file.
/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2009-2023 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 __MEMORY_NODES_H__
#define __MEMORY_NODES_H__
#include <starpu.h>
#include <common/config.h>
#include <datawizard/coherency.h>
#include <datawizard/memalloc.h>
#include <datawizard/node_ops.h>
#include <common/utils.h>
#include <core/workers.h>
#ifdef STARPU_SIMGRID
#include <core/simgrid.h>
#endif
#pragma GCC visibility push(hidden)
extern char _starpu_worker_drives_memory[STARPU_NMAXWORKERS][STARPU_MAXNODES];
struct _starpu_cond_and_worker
{
starpu_pthread_cond_t *cond;
struct _starpu_worker *worker;
};
// TODO: split out all these arrays into struct _starpu_node
struct _starpu_memory_node_descr
{
unsigned nnodes;
enum starpu_node_kind nodes[STARPU_MAXNODES];
const struct _starpu_node_ops *node_ops[STARPU_MAXNODES];
int devid[STARPU_MAXNODES];
unsigned nworkers[STARPU_MAXNODES];
#ifdef STARPU_SIMGRID
starpu_sg_host_t host[STARPU_MAXNODES];
#endif
// TODO move this 2 lists outside struct _starpu_memory_node_descr
starpu_pthread_rwlock_t conditions_rwlock;
struct _starpu_cond_and_worker conditions_attached_to_node[STARPU_MAXNODES][STARPU_NMAXWORKERS];
struct _starpu_cond_and_worker conditions_all[STARPU_MAXNODES*STARPU_NMAXWORKERS];
unsigned total_condition_count;
unsigned condition_count[STARPU_MAXNODES];
unsigned mapped[STARPU_MAXNODES];
};
extern struct _starpu_memory_node_descr _starpu_descr;
void _starpu_memory_nodes_init(void);
void _starpu_memory_nodes_deinit(void);
static inline void _starpu_memory_node_add_nworkers(unsigned node)
{
_starpu_descr.nworkers[node]++;
}
void _starpu_worker_drives_memory_node(struct _starpu_worker *worker, unsigned memnode);
static inline const struct _starpu_node_ops *_starpu_memory_node_get_node_ops(unsigned node)
{
return _starpu_descr.node_ops[node];
}
static inline unsigned _starpu_memory_node_get_nworkers(unsigned node)
{
return _starpu_descr.nworkers[node];
}
#ifdef STARPU_SIMGRID
static inline void _starpu_simgrid_memory_node_set_host(unsigned node, starpu_sg_host_t host)
{
_starpu_descr.host[node] = host;
}
static inline starpu_sg_host_t _starpu_simgrid_memory_node_get_host(unsigned node)
{
return _starpu_descr.host[node];
}
#endif
void _starpu_memory_node_set_mapped(unsigned node);
unsigned _starpu_memory_node_get_mapped(unsigned node);
unsigned _starpu_memory_node_register(enum starpu_node_kind kind, int devid);
//void _starpu_memory_node_attach_queue(struct starpu_jobq_s *q, unsigned nodeid);
void _starpu_memory_node_register_condition(struct _starpu_worker *worker, starpu_pthread_cond_t *cond, unsigned nodeid);
static inline struct _starpu_memory_node_descr *_starpu_memory_node_get_description(void)
{
return &_starpu_descr;
}
#define _starpu_node_needs_map_update(node) \
(starpu_node_get_kind(node) == STARPU_OPENCL_RAM)
static inline enum starpu_node_kind _starpu_node_get_kind(unsigned node)
{
return _starpu_descr.nodes[node];
}
#define starpu_node_get_kind _starpu_node_get_kind
#if STARPU_MAXNODES == 1
#define _starpu_memory_nodes_get_count() 1
#else
static inline unsigned _starpu_memory_nodes_get_count(void)
{
return _starpu_descr.nnodes;
}
#endif
#define starpu_memory_nodes_get_count _starpu_memory_nodes_get_count
#if STARPU_MAXNODES == 1
#define _starpu_worker_get_memory_node(workerid) 0
#else
static inline unsigned _starpu_worker_get_memory_node(unsigned workerid)
{
struct _starpu_machine_config *config = _starpu_get_machine_config();
unsigned nworkers = config->topology.nworkers;
if (workerid < config->topology.nworkers)
return config->workers[workerid].memory_node;
unsigned ncombinedworkers STARPU_ATTRIBUTE_UNUSED = config->topology.ncombinedworkers;
STARPU_ASSERT_MSG(workerid < ncombinedworkers + nworkers, "Bad workerid %u, maximum %u", workerid, ncombinedworkers + nworkers);
return config->combined_workers[workerid - nworkers].memory_node;
}
#endif
#define starpu_worker_get_memory_node _starpu_worker_get_memory_node
#if STARPU_MAXNODES == 1
#define _starpu_worker_get_local_memory_node() 0
#else
static inline unsigned _starpu_worker_get_local_memory_node(void)
{
struct _starpu_worker *worker = _starpu_get_local_worker_key();
if (!worker)
return STARPU_MAIN_RAM;
return worker->memory_node;
}
#endif
#define starpu_worker_get_local_memory_node _starpu_worker_get_local_memory_node
#pragma GCC visibility pop
#endif // __MEMORY_NODES_H__
coherency.h
starpu_node_kind
starpu_node_kind
Definition starpu_worker.h:44
memalloc.h
_starpu_memory_node_get_description
static struct _starpu_memory_node_descr * _starpu_memory_node_get_description(void)
Definition memory_nodes.h:126
_starpu_memory_node_register
unsigned _starpu_memory_node_register(enum starpu_node_kind kind, int devid)
_starpu_node_get_kind
static enum starpu_node_kind _starpu_node_get_kind(unsigned node)
Definition memory_nodes.h:135
_starpu_memory_node_set_mapped
void _starpu_memory_node_set_mapped(unsigned node)
_starpu_worker_drives_memory_node
void _starpu_worker_drives_memory_node(struct _starpu_worker *worker, unsigned memnode)
_starpu_memory_node_descr::conditions_rwlock
starpu_pthread_rwlock_t conditions_rwlock
Definition memory_nodes.h:66
_starpu_memory_node_get_nworkers
static unsigned _starpu_memory_node_get_nworkers(unsigned node)
Definition memory_nodes.h:95
_starpu_worker_get_local_memory_node
static unsigned _starpu_worker_get_local_memory_node(void)
Definition memory_nodes.h:179
_starpu_memory_node_register_condition
void _starpu_memory_node_register_condition(struct _starpu_worker *worker, starpu_pthread_cond_t *cond, unsigned nodeid)
_starpu_memory_node_descr::devid
int devid[STARPU_MAXNODES]
Definition memory_nodes.h:52
_starpu_memory_node_get_mapped
unsigned _starpu_memory_node_get_mapped(unsigned node)
_starpu_memory_nodes_get_count
static unsigned _starpu_memory_nodes_get_count(void)
Definition memory_nodes.h:145
_starpu_memory_node_descr::total_condition_count
unsigned total_condition_count
Definition memory_nodes.h:70
_starpu_memory_node_add_nworkers
static void _starpu_memory_node_add_nworkers(unsigned node)
Definition memory_nodes.h:81
_starpu_worker_get_memory_node
static unsigned _starpu_worker_get_memory_node(unsigned workerid)
Definition memory_nodes.h:156
_starpu_cond_and_worker
Definition memory_nodes.h:39
_starpu_memory_node_descr
Definition memory_nodes.h:46
node_ops.h
simgrid.h
_starpu_combined_worker::memory_node
unsigned memory_node
Definition workers.h:315
_starpu_machine_config
Definition workers.h:441
_starpu_machine_config::combined_workers
struct _starpu_combined_worker combined_workers[STARPU_NMAX_COMBINEDWORKERS]
Definition workers.h:475
_starpu_machine_config::workers
struct _starpu_worker workers[STARPU_NMAXWORKERS]
Definition workers.h:468
_starpu_machine_topology::nworkers
unsigned nworkers
Definition workers.h:354
_starpu_machine_topology::ncombinedworkers
unsigned ncombinedworkers
Definition workers.h:357
_starpu_node_ops
Definition node_ops.h:92
_starpu_worker
Definition workers.h:155
_starpu_worker::memory_node
unsigned memory_node
Definition workers.h:172
_starpu_worker::workerid
int workerid
Definition workers.h:166
utils.h