standard_memory_library.doxy 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2009--2011 Universit@'e de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2017 CNRS
  5. * Copyright (C) 2011, 2012 INRIA
  6. * See the file version.doxy for copying conditions.
  7. */
  8. /*! \defgroup API_Standard_Memory_Library Standard Memory Library
  9. \def starpu_ssize_t
  10. \ingroup API_Standard_Memory_Library
  11. todo
  12. \def starpu_data_malloc_pinned_if_possible
  13. \ingroup API_Standard_Memory_Library
  14. \deprecated
  15. Equivalent to starpu_malloc(). This macro is provided to avoid breaking old codes.
  16. \def starpu_data_free_pinned_if_possible
  17. \ingroup API_Standard_Memory_Library
  18. \deprecated
  19. Equivalent to starpu_free(). This macro is provided to avoid breaking old codes.
  20. \def STARPU_MALLOC_PINNED
  21. \ingroup API_Standard_Memory_Library
  22. Value passed to the function starpu_malloc_flags() to indicate the memory allocation should be pinned.
  23. \def STARPU_MALLOC_COUNT
  24. \ingroup API_Standard_Memory_Library
  25. Value passed to the function starpu_malloc_flags() to indicate
  26. the memory allocation should be in the limit defined by the
  27. environment variables \ref STARPU_LIMIT_CUDA_devid_MEM,
  28. \ref STARPU_LIMIT_CUDA_MEM, \ref STARPU_LIMIT_OPENCL_devid_MEM,
  29. \ref STARPU_LIMIT_OPENCL_MEM and \ref STARPU_LIMIT_CPU_MEM (see
  30. Section \ref HowToLimitMemoryPerNode).
  31. If no memory is available, it tries to reclaim memory from StarPU.
  32. Memory allocated this way needs to be freed by calling the function
  33. starpu_free_flags() with the same flag.
  34. \def STARPU_MALLOC_NORECLAIM
  35. \ingroup API_Standard_Memory_Library
  36. Value passed to the function starpu_malloc_flags() along ::STARPU_MALLOC_COUNT
  37. to indicate that while the memory allocation should be kept in the limits
  38. defined for ::STARPU_MALLOC_COUNT, no reclaiming should be performed by
  39. starpu_malloc_flags() itself, thus potentially overflowing the
  40. memory node a bit. StarPU will reclaim memory after next task termination,
  41. according to \ref STARPU_MINIMUM_AVAILABLE_MEM and \ref STARPU_TARGET_AVAILABLE_MEM
  42. environment variables. If ::STARPU_MEMORY_WAIT is set, no overflowing will happen,
  43. starpu_malloc_flags() will wait for other eviction mechanisms to release enough memory.
  44. \def STARPU_MALLOC_SIMULATION_FOLDED
  45. \ingroup API_Standard_Memory_Library
  46. Value passed to the function starpu_malloc_flags() to indicate that when
  47. StarPU is using simgrid, the allocation can be "folded", i.e. a memory area is
  48. allocated, but its content is actually a replicate of the same memory area, to
  49. avoid having to actually allocate that much memory . This thus allows to have a
  50. memory area that does not actually consumes memory, to which one can read from
  51. and write to normally, but get bogus values.
  52. \fn int starpu_malloc_flags(void **A, size_t dim, int flags)
  53. \ingroup API_Standard_Memory_Library
  54. Perform a memory allocation based on the constraints defined
  55. by the given flag.
  56. \fn void starpu_malloc_set_align(size_t align)
  57. \ingroup API_Standard_Memory_Library
  58. Set an alignment constraints for starpu_malloc()
  59. allocations. \p align must be a power of two. This is for instance called
  60. automatically by the OpenCL driver to specify its own alignment
  61. constraints.
  62. \fn int starpu_malloc(void **A, size_t dim)
  63. \ingroup API_Standard_Memory_Library
  64. Allocate data of the given size \p dim in main memory, and
  65. return the pointer to the allocated data through \p A.
  66. It will also try to pin it in CUDA or OpenCL, so that data transfers
  67. from this buffer can be asynchronous, and thus permit data transfer
  68. and computation overlapping. The allocated buffer must be freed thanks
  69. to the starpu_free() function.
  70. \fn int starpu_free(void *A)
  71. \ingroup API_Standard_Memory_Library
  72. Free memory which has previously been allocated with starpu_malloc().
  73. \fn int starpu_free_flags(void *A, size_t dim, int flags)
  74. \ingroup API_Standard_Memory_Library
  75. Free memory by specifying its size. The given
  76. flags should be consistent with the ones given to starpu_malloc_flags()
  77. when allocating the memory.
  78. \fn int starpu_memory_pin(void *addr, size_t size)
  79. \ingroup API_Standard_Memory_Library
  80. Pin the given memory area, so that CPU-GPU transfers can be done
  81. asynchronously with DMAs. The memory must be unpinned with
  82. starpu_memory_unpin() before being freed. Returns 0 on success, -1 on error.
  83. \fn int starpu_memory_unpin(void *addr, size_t size)
  84. \ingroup API_Standard_Memory_Library
  85. Unpin the given memory area previously pinned with
  86. starpu_memory_pin(). Returns 0 on success, -1 on error.
  87. \fn ssize_t starpu_memory_get_total(unsigned node)
  88. \ingroup API_Standard_Memory_Library
  89. If a memory limit is defined on the given node (see Section
  90. \ref HowToLimitMemoryPerNode), return the amount of total memory
  91. on the node. Otherwise return -1.
  92. \fn ssize_t starpu_memory_get_total_all_nodes()
  93. \ingroup API_Standard_Memory_Library
  94. Return the amount of total memory on all memory nodes for whose a memory limit
  95. is defined (see Section \ref HowToLimitMemoryPerNode).
  96. \fn ssize_t starpu_memory_get_available(unsigned node)
  97. \ingroup API_Standard_Memory_Library
  98. If a memory limit is defined on the given node (see Section
  99. \ref HowToLimitMemoryPerNode), return the amount of available memory
  100. on the node. Otherwise return -1.
  101. \fn ssize_t starpu_memory_get_available_all_nodes()
  102. \ingroup API_Standard_Memory_Library
  103. Return the amount of available memory on all memory nodes for whose a memory limit
  104. is defined (see Section \ref HowToLimitMemoryPerNode).
  105. \fn int starpu_memory_allocate(unsigned node, size_t size, int flags)
  106. \ingroup API_Standard_Memory_Library
  107. If a memory limit is defined on the given node (see Section
  108. \ref HowToLimitMemoryPerNode), try to allocate some of it. This does not actually
  109. allocate memory, but only accounts for it. This can be useful when the
  110. application allocates data another way, but want StarPU to be aware of the
  111. allocation size e.g. for memory reclaiming.
  112. By default, the function returns <c>-ENOMEM</c> if there is not enough room on
  113. the given node. \p flags can be either ::STARPU_MEMORY_WAIT or
  114. ::STARPU_MEMORY_OVERFLOW to change this.
  115. \fn void starpu_memory_deallocate(unsigned node, size_t size)
  116. \ingroup API_Standard_Memory_Library
  117. If a memory limit is defined on the given node (see Section
  118. \ref HowToLimitMemoryPerNode), free some of it. This does not actually free memory,
  119. but only accounts for it, like starpu_memory_allocate(). The amount does not
  120. have to be exactly the same as what was passed to starpu_memory_allocate(),
  121. only the eventual amount needs to be the same, i.e. one call to
  122. starpu_memory_allocate() can be followed by several calls to
  123. starpu_memory_deallocate() to declare the deallocation piece by piece.
  124. \fn void starpu_memory_wait_available(unsigned node, size_t size)
  125. \ingroup API_Standard_Memory_Library
  126. If a memory limit is defined on the given
  127. node (see Section \ref HowToLimitMemoryPerNode), this will wait for \p size
  128. bytes to become available on \p node. Of course, since another thread may be
  129. allocating memory concurrently, this does not necessarily mean that this amount
  130. will be actually available, just that it was reached. To atomically wait for
  131. some amount of memory and reserve it, starpu_memory_allocate() should be used
  132. with the ::STARPU_MEMORY_WAIT flag.
  133. \def STARPU_MEMORY_WAIT
  134. \ingroup API_Standard_Memory_Library
  135. Value passed to starpu_memory_allocate() to specify that the function should
  136. wait for the requested amount of memory to become available, and atomically
  137. allocate it.
  138. \def STARPU_MEMORY_OVERFLOW
  139. \ingroup API_Standard_Memory_Library
  140. Value passed to starpu_memory_allocate() to specify that the function should
  141. allocate the amount of memory, even if that means overflowing the total size of
  142. the memory node.
  143. */