starpu_stdlib.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013,2015-2017,2019 CNRS
  4. * Copyright (C) 2017 Inria
  5. * Copyright (C) 2010-2016,2019 Université de Bordeaux
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #ifndef __STARPU_STDLIB_H__
  19. #define __STARPU_STDLIB_H__
  20. /** @defgroup
  21. *
  22. * @{
  23. */
  24. #include <starpu.h>
  25. #ifdef __cplusplus
  26. extern "C"
  27. {
  28. #endif
  29. #define STARPU_MALLOC_PINNED ((1ULL)<<1)
  30. #define STARPU_MALLOC_COUNT ((1ULL)<<2)
  31. #define STARPU_MALLOC_NORECLAIM ((1ULL)<<3)
  32. #define STARPU_MEMORY_WAIT ((1ULL)<<4)
  33. #define STARPU_MEMORY_OVERFLOW ((1ULL)<<5)
  34. #define STARPU_MALLOC_SIMULATION_FOLDED ((1ULL)<<6)
  35. /**
  36. \deprecated
  37. Equivalent to starpu_malloc(). This macro is provided to avoid
  38. breaking old codes.
  39. */
  40. #define starpu_data_malloc_pinned_if_possible starpu_malloc
  41. #define starpu_data_free_pinned_if_possible starpu_free
  42. void starpu_malloc_set_align(size_t align);
  43. int starpu_malloc(void **A, size_t dim);
  44. int starpu_free(void *A);
  45. int starpu_malloc_flags(void **A, size_t dim, int flags);
  46. int starpu_free_flags(void *A, size_t dim, int flags);
  47. typedef int (*starpu_malloc_hook)(unsigned dst_node, void **A, size_t dim, int flags);
  48. typedef int (*starpu_free_hook)(unsigned dst_node, void *A, size_t dim, int flags);
  49. void starpu_malloc_set_hooks(starpu_malloc_hook malloc_hook, starpu_free_hook free_hook);
  50. int starpu_memory_pin(void *addr, size_t size);
  51. int starpu_memory_unpin(void *addr, size_t size);
  52. starpu_ssize_t starpu_memory_get_total(unsigned node);
  53. starpu_ssize_t starpu_memory_get_available(unsigned node);
  54. starpu_ssize_t starpu_memory_get_total_all_nodes();
  55. starpu_ssize_t starpu_memory_get_available_all_nodes();
  56. void starpu_memory_wait_available(unsigned node, size_t size);
  57. /* Try to allocate memory on the given node */
  58. int starpu_memory_allocate(unsigned node, size_t size, int flags);
  59. /* Indicates the given amount of memory is going to be deallocated from the given node */
  60. void starpu_memory_deallocate(unsigned node, size_t size);
  61. void starpu_sleep(float nb_sec);
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. /** @} */
  66. #endif /* __STARPU_STDLIB_H__ */