mem_utils.hpp 841 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include <cstdlib>
  8. #include <pvfmm_common.hpp>
  9. #ifndef _PVFMM_MEM_UTILS_
  10. #define _PVFMM_MEM_UTILS_
  11. #ifdef __INTEL_OFFLOAD
  12. #pragma offload_attribute(push,target(mic))
  13. #endif
  14. namespace pvfmm{
  15. namespace mem{
  16. // Aligned memory allocation.
  17. // Alignment must be power of 2 (1,2,4,8,16...)
  18. template <class T>
  19. T* aligned_malloc(size_t size_, size_t alignment=MEM_ALIGN);
  20. // Aligned memory free.
  21. template <class T>
  22. void aligned_free(T* p_);
  23. void * memcopy ( void * destination, const void * source, size_t num );
  24. }//end namespace
  25. }//end namespace
  26. #ifdef __INTEL_OFFLOAD
  27. #pragma offload_attribute(pop)
  28. #endif
  29. #include <mem_utils.txx>
  30. #endif //_PVFMM_MEM_UTILS_