-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathumpireInterface.cpp
More file actions
79 lines (64 loc) · 1.97 KB
/
umpireInterface.cpp
File metadata and controls
79 lines (64 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors.
* All rights reserved.
* See the LICENSE file for details.
* SPDX-License-Identifier: (BSD-3-Clause)
*/
// Source includes
#include "LvArrayConfig.hpp"
#include "umpireInterface.hpp"
// TPL includes
#if defined( LVARRAY_USE_UMPIRE )
#include <umpire/ResourceManager.hpp>
#endif
// System includes
#include <cstring>
namespace LvArray
{
namespace umpireInterface
{
void copy( void * const dstPointer, void * const srcPointer, std::size_t const size )
{
#if defined( LVARRAY_USE_UMPIRE )
umpire::ResourceManager & rm = umpire::ResourceManager::getInstance();
if( rm.hasAllocator( dstPointer ) && rm.hasAllocator( srcPointer ) )
{
rm.copy( dstPointer, srcPointer, size );
return;
}
#endif
std::memcpy( dstPointer, srcPointer, size );
}
camp::resources::Event copy( void * const dstPointer, void * const srcPointer,
camp::resources::Resource & resource, std::size_t const size )
{
#if defined( LVARRAY_USE_UMPIRE )
umpire::ResourceManager & rm = umpire::ResourceManager::getInstance();
bool const allocatedByUmpire = rm.hasAllocator( dstPointer ) && rm.hasAllocator( srcPointer );
// Umpire breaks if you supply a host resource.
if( allocatedByUmpire && resource.try_get< camp::resources::Host >() )
{
rm.copy( dstPointer, srcPointer, size );
return resource.get_event();
}
if( allocatedByUmpire )
{
return rm.copy( dstPointer, srcPointer, resource, size );
}
#endif
std::memcpy( dstPointer, srcPointer, size );
return resource.get_event();
}
void memset( void * const dstPointer, int const val, std::size_t const size )
{
#if defined( LVARRAY_USE_UMPIRE )
umpire::ResourceManager & rm = umpire::ResourceManager::getInstance();
if( rm.hasAllocator( dstPointer ) )
{
return rm.memset( dstPointer, val, size );
}
#endif
std::memset( dstPointer, val, size );
}
} // namespace umpireInterface
} // namespace LvArray