| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 | /* * This file is part of the StarPU Handbook. * Copyright (C) 2009--2011  Universit@'e de Bordeaux * Copyright (C) 2010, 2011, 2012, 2013, 2015  CNRS * Copyright (C) 2011, 2012 INRIA * See the file version.doxy for copying conditions. *//*! \defgroup API_Standard_Memory_Library Standard Memory Library\def starpu_data_malloc_pinned_if_possible\ingroup API_Standard_Memory_Library\deprecatedEquivalent to starpu_malloc(). This macro is provided to avoid breaking old codes.\def starpu_data_free_pinned_if_possible\ingroup API_Standard_Memory_Library\deprecatedEquivalent to starpu_free(). This macro is provided to avoid breaking old codes.\def STARPU_MALLOC_PINNED\ingroup API_Standard_Memory_LibraryValue passed to the function starpu_malloc_flags() to indicate the memory allocation should be pinned.\def STARPU_MALLOC_COUNT\ingroup API_Standard_Memory_LibraryValue passed to the function starpu_malloc_flags() to indicatethe memory allocation should be in the limit defined by theenvironment variables \ref STARPU_LIMIT_CUDA_devid_MEM,\ref STARPU_LIMIT_CUDA_MEM, \ref STARPU_LIMIT_OPENCL_devid_MEM,\ref STARPU_LIMIT_OPENCL_MEM and \ref STARPU_LIMIT_CPU_MEM (seeSection \ref HowToLimitMemoryPerNode).If no memory is available, it tries to reclaim memory from StarPU.Memory allocated this way needs to be freed by calling the functionstarpu_free_flags() with the same flag.\def STARPU_MALLOC_NORECLAIM\ingroup API_Standard_Memory_LibraryValue passed to the function starpu_malloc_flags() along STARPU_MALLOC_COUNTto indicate that while the memory allocation should be kept in the limitsdefined for STARPU_MALLOC_COUNT, no reclaiming should be performed bystarpu_malloc_flags itself, thus potentially overflowing thememory node a bit. StarPU will reclaim memory after next task termination,according to the STARPU_MINIMUM_AVAILABLE_MEM and STARPU_TARGET_AVAILABLE_MEMenvironment variables. If STARPU_MEMORY_WAIT is set, no overflowing will happen,starpu_malloc_flags() will wait for other eviction mechanisms to release enough memory.\def STARPU_MALLOC_SIMULATION_FOLDED\ingroup API_Standard_Memory_LibraryValue passed to the function starpu_malloc_flags() to indicate that whenStarPU is using simgrid, the allocation can be "folded", i.e. a memory area isallocated, but its content is actually a replicate of the same memory area, toavoid having to actually allocate that much memory . This thus allows to have amemory area that does not actually consumes memory, to which one can read fromand write to normally, but get bogus values.\fn int starpu_malloc_flags(void **A, size_t dim, int flags)\ingroup API_Standard_Memory_LibraryPerforms a memory allocation based on the constraints definedby the given flag.\fn void starpu_malloc_set_align(size_t align)\ingroup API_Standard_Memory_LibraryThis function sets an alignment constraints for starpu_malloc()allocations. align must be a power of two. This is for instance calledautomatically by the OpenCL driver to specify its own alignmentconstraints.\fn int starpu_malloc(void **A, size_t dim)\ingroup API_Standard_Memory_LibraryThis function allocates data of the given size in main memory.It will also try to pin it in CUDA or OpenCL, so that data transfersfrom this buffer can be asynchronous, and thus permit data transferand computation overlapping. The allocated buffer must be freed thanksto the starpu_free() function.\fn int starpu_free(void *A)\ingroup API_Standard_Memory_LibraryThis function frees memory which has previously been allocatedwith starpu_malloc().\fn int starpu_free_flags(void *A, size_t dim, int flags)\ingroup API_Standard_Memory_LibraryThis function frees memory by specifying its size. The givenflags should be consistent with the ones given to starpu_malloc_flags()when allocating the memory.\fn int starpu_memory_pin(void *addr, size_t size)\ingroup API_Standard_Memory_LibraryThis function pins the given memory area, so that CPU-GPU transfers can be doneasynchronously with DMAs. The memory must be unpinned withstarpu_memory_unpin() before being freed. Returns 0 on success, -1 on error.\fn int starpu_memory_unpin(void *addr, size_t size)\ingroup API_Standard_Memory_LibraryThis function unpins the given memory area previously pinned withstarpu_memory_pin(). Returns 0 on success, -1 on error.\fn ssize_t starpu_memory_get_total(unsigned node)\ingroup API_Standard_Memory_LibraryIf a memory limit is defined on the given node (see Section \refHowToLimitMemoryPerNode), return the amount of total memoryon the node. Otherwise return -1.\fn ssize_t starpu_memory_get_available(unsigned node)\ingroup API_Standard_Memory_LibraryIf a memory limit is defined on the given node (see Section \refHowToLimitMemoryPerNode), return the amount of available memoryon the node. Otherwise return -1.\fn int starpu_memory_allocate(unsigned node, size_t size, int flags)\ingroup API_Standard_Memory_LibraryIf a memory limit is defined on the given node (see Section \refHowToLimitMemoryPerNode), try to allocate some of it. This does not actuallyallocate memory, but only accounts for it. This can be useful when theapplication allocates data another way, but want StarPU to be aware of theallocation size e.g. for memory reclaiming.By default, the function returns -ENOMEM if there is not enough room onthe given node. \p flags can be either STARPU_MEMORY_WAIT orSTARPU_MEMORY_OVERFLOW to change this.\fn void starpu_memory_deallocate(unsigned node, size_t size)\ingroup API_Standard_Memory_LibraryIf a memory limit is defined on the given node (see Section \refHowToLimitMemoryPerNode), free some of it. This does not actually free memory,but only accounts for it, like starpu_memory_allocate(). The amount does nothave to be exactly the same as what was passed to starpu_memory_allocate(),only the eventual amount needs to be the same, i.e. one call tostarpu_memory_allocate() can be followed by several calls tostarpu_memory_deallocate() to declare the deallocation piece by piece.\fn void starpu_memory_wait_available(unsigned node, size_t size)\ingroup API_Standard_Memory_LibraryIf a memory limit is defined on the givennode (see Section \ref HowToLimitMemoryPerNode), this will wait for \p sizebytes to become available on \p node. Of course, since another thread may beallocating memory concurrently, this does not necessarily mean that this amountwill be actually available, just that it was reached. To atomically wait forsome amount of memory and reserve it, starpu_memory_allocate() should be usedwith the STARPU_MEMORY_WAIT flag.\def STARPU_MEMORY_WAIT\ingroup API_Standard_Memory_LibraryValue passed to starpu_memory_allocate() to specify that the function shouldwait for the requested amount of memory to become available, and atomicallyallocate it.\def STARPU_MEMORY_OVERFLOW\ingroup API_Standard_Memory_LibraryValue passed to starpu_memory_allocate() to specify that the function shouldallocate the amount of memory, even if that means overflowing the total size ofthe memory node.*/
 |