memory_nodes.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __MEMORY_NODES_H__
  17. #define __MEMORY_NODES_H__
  18. #include <starpu.h>
  19. #include <common/config.h>
  20. #include <datawizard/coherency.h>
  21. #include <datawizard/memalloc.h>
  22. typedef enum {
  23. STARPU_UNUSED = 0x00,
  24. STARPU_CPU_RAM = 0x01,
  25. STARPU_CUDA_RAM = 0x02,
  26. STARPU_OPENCL_RAM = 0x03,
  27. STARPU_SPU_LS = 0x04
  28. } starpu_node_kind;
  29. typedef starpu_node_kind starpu_memory_node_tuple;
  30. #define _STARPU_MEMORY_NODE_TUPLE(node1,node2) (node1 | (node2 << 4))
  31. #define _STARPU_MEMORY_NODE_TUPLE_FIRST(tuple) (tuple & 0x0F)
  32. #define _STARPU_MEMORY_NODE_TUPLE_SECOND(tuple) (tuple & 0xF0)
  33. typedef struct {
  34. unsigned nnodes;
  35. starpu_node_kind nodes[STARPU_MAXNODES];
  36. /* the list of queues that are attached to a given node */
  37. // XXX 32 is set randomly !
  38. // TODO move this 2 lists outside starpu_mem_node_descr
  39. pthread_rwlock_t attached_queues_rwlock;
  40. struct starpu_jobq_s *attached_queues_per_node[STARPU_MAXNODES][32];
  41. struct starpu_jobq_s *attached_queues_all[STARPU_MAXNODES*32];
  42. /* the number of queues attached to each node */
  43. unsigned total_queues_count;
  44. unsigned queues_count[STARPU_MAXNODES];
  45. } starpu_mem_node_descr;
  46. void _starpu_init_memory_nodes(void);
  47. void _starpu_deinit_memory_nodes(void);
  48. void _starpu_set_local_memory_node_key(unsigned *node);
  49. unsigned _starpu_get_local_memory_node(void);
  50. unsigned _starpu_register_memory_node(starpu_node_kind kind);
  51. void _starpu_memory_node_attach_queue(struct starpu_jobq_s *q, unsigned nodeid);
  52. starpu_node_kind _starpu_get_node_kind(uint32_t node);
  53. unsigned _starpu_get_memory_nodes_count(void);
  54. inline starpu_mem_node_descr *_starpu_get_memory_node_description(void);
  55. #endif // __MEMORY_NODES_H__