401_out_of_core.doxy 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2013 Corentin Salingue
  4. * See the file version.doxy for copying conditions.
  5. */
  6. /*! \page OutOfCore Out Of Core
  7. \section Introduction Introduction
  8. When using StarPU, one may need to store more data than what the main memory
  9. (RAM) can store. This part describes the method to add a new memory node on a
  10. disk and to use it.
  11. The principle is that one first registers a disk location, seen by StarPU as
  12. a <c>void*</c>, which can be for instance a Unix path for the stdio, unistd or unistd_o_direct case,
  13. or a database file path for a leveldb case, etc. The disk backend opens this
  14. place with the plug method.
  15. If the disk backend provides an alloc method, StarPU can then start using it
  16. to allocate room and store data there with the write method, without user
  17. intervention.
  18. The user can also use starpu_disk_open() to explicitly open an object within the
  19. disk, e.g. a file name in the stdio or unistd cases, or a database key in the
  20. leveldb case, and then use <c>starpu_*_register</c> functions to turn it into a StarPU
  21. data handle. StarPU will then automatically read and write data as appropriate.
  22. \section UseANewDiskMemory Use a new disk memory
  23. To use a disk memory node, you have to register it with this function:
  24. \code{.c}
  25. int new_dd = starpu_disk_register(&starpu_disk_unistd_ops, (void *) "/tmp/", 1024*1024*200);
  26. \endcode
  27. Here, we use the unistd library to realize the read/write operations, i.e.
  28. fread/fwrite. This structure must have a path where to store files, as well as
  29. the maximum size the software can afford storing on the disk.
  30. Don't forget to check if the result is correct!
  31. This can also be achieved by just setting environment variables:
  32. \verbatim
  33. export STARPU_DISK_SWAP=/tmp
  34. export STARPU_DISK_SWAP_BACKEND=unistd
  35. export STARPU_DISK_SWAP_SIZE=200
  36. \endverbatim
  37. The backend can be set to stdio, unistd, unistd_o_direct, or leveldb.
  38. When the register function is called, StarPU will benchmark the disk. This can
  39. take some time.
  40. <strong>Warning: the size thus has to be at least \ref STARPU_DISK_SIZE_MIN bytes ! </strong>
  41. StarPU will automatically try to evict unused data to this new disk. One can
  42. also use the standard StarPU memory node API, see the \ref API_Standard_Memory_Library
  43. and the \ref API_Data_Interfaces .
  44. The disk is unregistered during the starpu_shutdown().
  45. \section DiskFunctions Disk functions
  46. There are various ways to operate a disk memory node, described by the structure
  47. starpu_disk_ops. For instance, the variable #starpu_disk_unistd_ops
  48. uses read/write functions.
  49. All structures are in \ref API_Out_Of_Core.
  50. \section ExampleDiskCopy Examples: disk_copy
  51. \snippet disk_copy.c To be included. You should update doxygen if you see this text.
  52. \section ExampleDiskCompute Examples: disk_compute
  53. \snippet disk_compute.c To be included. You should update doxygen if you see this text.
  54. */