mem_utils.hpp 953 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * \file mat_utils.hpp
  3. * \author Dhairya Malhotra, dhairya.malhotra@gmail.com
  4. * \date 11-5-2013
  5. * \brief This file contains memory management utilities.
  6. */
  7. #ifndef _PVFMM_MEM_UTILS_
  8. #define _PVFMM_MEM_UTILS_
  9. #include <cstdlib>
  10. #include <pvfmm_common.hpp>
  11. #define ALLOC alloc_if(1) free_if(0)
  12. #define FREE alloc_if(0) free_if(1)
  13. #define REUSE alloc_if(0) free_if(0)
  14. #ifdef __INTEL_OFFLOAD
  15. #pragma offload_attribute(push,target(mic))
  16. #endif
  17. namespace pvfmm{
  18. namespace mem{
  19. // Aligned memory allocation.
  20. // Alignment must be power of 2 (1,2,4,8,16...)
  21. template <class T>
  22. T* aligned_malloc(size_t size_, size_t alignment=MEM_ALIGN);
  23. // Aligned memory free.
  24. template <class T>
  25. void aligned_free(T* p_);
  26. void * memcopy ( void * destination, const void * source, size_t num );
  27. }//end namespace
  28. }//end namespace
  29. #ifdef __INTEL_OFFLOAD
  30. #pragma offload_attribute(pop)
  31. #endif
  32. #include <mem_utils.txx>
  33. #endif //_PVFMM_MEM_UTILS_