| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Stokhos Package |
| 4 |
// |
| 5 |
// Copyright 2009 NTESS and the Stokhos contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#include <new> |
| 11 |
|
| 12 |
#include "Stokhos_MemoryTraits.hpp" |
| 13 |
|
| 14 |
// When aligning memory fo the MIC architecture, we need to globally replace |
| 15 |
// new/delete with aligned versions because of seg faults in the MueLu setup. |
| 16 |
// This is true even though MP::Vector provides its own aligned new/delete |
| 17 |
// overloads, as well as aligned STL allocators. Somewhere in the MueLu setup |
| 18 |
// code, a raw new/delete must be called. |
| 19 |
// |
| 20 |
// Note, this still doesn't resolve seg faults for MIC when using (Intel) MPI. |
| 21 |
|
| 22 |
#if STOKHOS_ALIGN_MEMORY && defined(__MIC__) |
| 23 |
void* operator new(std::size_t count) throw (std::bad_alloc) { |
| 24 |
return Stokhos::MemoryTraits< Kokkos::HostSpace >::alloc(count); |
| 25 |
} |
| 26 |
void* operator new[](std::size_t count) throw (std::bad_alloc) { |
| 27 |
return Stokhos::MemoryTraits< Kokkos::HostSpace >::alloc(count); |
| 28 |
} |
| 29 |
void operator delete(void *ptr) throw() { |
| 30 |
Stokhos::MemoryTraits< Kokkos::HostSpace >::free(ptr); |
| 31 |
} |
| 32 |
void operator delete[](void *ptr) throw() { |
| 33 |
Stokhos::MemoryTraits< Kokkos::HostSpace >::free(ptr); |
| 34 |
} |
| 35 |
#endif |