memalloc.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010, 2012-2013 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #ifndef __MEMALLOC_H__
  18. #define __MEMALLOC_H__
  19. #include <starpu.h>
  20. #include <common/config.h>
  21. #include <common/list.h>
  22. #include <datawizard/interfaces/data_interface.h>
  23. #include <datawizard/coherency.h>
  24. #include <datawizard/copy_driver.h>
  25. struct _starpu_data_replicate;
  26. LIST_TYPE(_starpu_mem_chunk,
  27. starpu_data_handle_t data;
  28. uint32_t footprint;
  29. /* The footprint of the data is not sufficient to determine whether two
  30. * pieces of data have the same layout (there could be collision in the
  31. * hash function ...) so we still keep a copy of the actual layout (ie.
  32. * the data interface) to stay on the safe side. We make a copy of
  33. * because when a data is deleted, the memory chunk remains.
  34. */
  35. struct starpu_data_interface_ops *ops;
  36. void *chunk_interface;
  37. size_t size_interface;
  38. unsigned automatically_allocated;
  39. /* the size of the data is only set when calling _starpu_request_mem_chunk_removal(),
  40. * it is needed by free_memory_on_node() which is called when
  41. * the handle is no longer valid. It should not be used otherwise.
  42. */
  43. size_t size;
  44. /* A buffer that is used for SCRATCH or reduction cannnot be used with
  45. * filters. */
  46. unsigned relaxed_coherency;
  47. struct _starpu_data_replicate *replicate;
  48. )
  49. /* LRU list */
  50. LIST_TYPE(_starpu_mem_chunk_lru,
  51. struct _starpu_mem_chunk *mc;
  52. )
  53. void _starpu_init_mem_chunk_lists(void);
  54. void _starpu_deinit_mem_chunk_lists(void);
  55. void _starpu_request_mem_chunk_removal(starpu_data_handle_t handle, struct _starpu_data_replicate *replicate, unsigned node, size_t size);
  56. int _starpu_allocate_memory_on_node(starpu_data_handle_t handle, struct _starpu_data_replicate *replicate, unsigned is_prefetch);
  57. size_t _starpu_free_all_automatically_allocated_buffers(unsigned node);
  58. void _starpu_memchunk_recently_used(struct _starpu_mem_chunk *mc, unsigned node);
  59. void _starpu_display_memory_stats_by_node(int node);
  60. size_t _starpu_memory_reclaim_generic(unsigned node, unsigned force, size_t reclaim);
  61. #endif