| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 | /* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2010-2013,2015-2017                      CNRS * Copyright (C) 2009-2011,2014-2017                      Université de Bordeaux * Copyright (C) 2011,2012                                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. *//*! \defgroup API_Standard_Memory_Library Standard Memory Library\def starpu_ssize_t\ingroup API_Standard_Memory_Librarytodo\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 \ref STARPU_MINIMUM_AVAILABLE_MEM, \ref STARPU_TARGET_AVAILABLE_MEM,\ref STARPU_MINIMUM_CLEAN_BUFFERS, and \ref STARPU_TARGET_CLEAN_BUFFERSenvironment 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_LibraryPerform a memory allocation based on the constraints definedby the given flag.\fn void starpu_malloc_set_align(size_t align)\ingroup API_Standard_Memory_LibrarySet an alignment constraints for starpu_malloc()allocations. \p 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_LibraryAllocate data of the given size \p dim in main memory, andreturn the pointer to the allocated data through \p A.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_LibraryFree memory which has previously been allocated with starpu_malloc().\fn int starpu_free_flags(void *A, size_t dim, int flags)\ingroup API_Standard_Memory_LibraryFree 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_LibraryPin 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_LibraryUnpin 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\ref HowToLimitMemoryPerNode), return the amount of total memoryon the node. Otherwise return -1.\fn ssize_t starpu_memory_get_total_all_nodes()\ingroup API_Standard_Memory_LibraryReturn the amount of total memory on all memory nodes for whose a memory limitis defined (see Section \ref HowToLimitMemoryPerNode).\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\ref HowToLimitMemoryPerNode), return the amount of available memoryon the node. Otherwise return -1.\fn ssize_t starpu_memory_get_available_all_nodes()\ingroup API_Standard_Memory_LibraryReturn the amount of available memory on all memory nodes for whose a memory limitis defined (see Section \ref HowToLimitMemoryPerNode).\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\ref HowToLimitMemoryPerNode), 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 <c>-ENOMEM</c> if there is not enough room onthe given node. \p flags can be either ::STARPU_MEMORY_WAIT or::STARPU_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\ref HowToLimitMemoryPerNode), 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.*/
 |