58
58
static void * opal_datatype_accelerator_memcpy (void * dest , const void * src , size_t size )
59
59
{
60
60
int res ;
61
- int dev_id ;
61
+ int dst_type , dst_dev , src_type , src_dev ;
62
+ int copy_type = MCA_ACCELERATOR_TRANSFER_DTOD ;
62
63
uint64_t flags ;
63
64
/* If accelerator check addr returns an error, we can only
64
65
* assume it is a host buffer. If device buffer checking fails,
@@ -67,12 +68,19 @@ static void *opal_datatype_accelerator_memcpy(void *dest, const void *src, size_
67
68
* and retries are also unlikely to succeed. We identify these
68
69
* buffers as host buffers as attempting a memcpy would provide
69
70
* a chance to succeed. */
70
- if (0 >= opal_accelerator .check_addr (dest , & dev_id , & flags ) &&
71
- 0 >= opal_accelerator .check_addr (src , & dev_id , & flags )) {
71
+ dst_type = opal_accelerator .check_addr (dest , & dst_dev , & flags );
72
+ src_type = opal_accelerator .check_addr (src , & src_dev , & flags );
73
+ if (0 >= dst_type && 0 >= src_type ) {
72
74
return memcpy (dest , src , size );
73
75
}
74
- res = opal_accelerator .mem_copy (MCA_ACCELERATOR_NO_DEVICE_ID , MCA_ACCELERATOR_NO_DEVICE_ID ,
75
- dest , src , size , MCA_ACCELERATOR_TRANSFER_UNSPEC );
76
+ else if (0 >= dst_type && 0 < src_type ) {
77
+ copy_type = MCA_ACCELERATOR_TRANSFER_DTOH ;
78
+ }
79
+ else if (0 < dst_type && 0 >= dst_type ) {
80
+ copy_type = MCA_ACCELERATOR_TRANSFER_HTOD ;
81
+ }
82
+ res = opal_accelerator .mem_copy (dst_dev , src_dev ,
83
+ dest , src , size , copy_type );
76
84
if (OPAL_SUCCESS != res ) {
77
85
opal_output (0 , "Error in accelerator memcpy" );
78
86
abort ();
@@ -83,7 +91,8 @@ static void *opal_datatype_accelerator_memcpy(void *dest, const void *src, size_
83
91
static void * opal_datatype_accelerator_memmove (void * dest , const void * src , size_t size )
84
92
{
85
93
int res ;
86
- int dev_id ;
94
+ int dst_type , dst_dev , src_type , src_dev ;
95
+ int copy_type = MCA_ACCELERATOR_TRANSFER_DTOD ;
87
96
uint64_t flags ;
88
97
/* If accelerator check addr returns an error, we can only
89
98
* assume it is a host buffer. If device buffer checking fails,
@@ -92,12 +101,19 @@ static void *opal_datatype_accelerator_memmove(void *dest, const void *src, size
92
101
* and retries are also unlikely to succeed. We identify these
93
102
* buffers as host buffers as attempting a memmove would provide
94
103
* a chance to succeed. */
95
- if (0 >= opal_accelerator .check_addr (dest , & dev_id , & flags ) &&
96
- 0 >= opal_accelerator .check_addr (src , & dev_id , & flags )) {
104
+ dst_type = opal_accelerator .check_addr (dest , & dst_dev , & flags );
105
+ src_type = opal_accelerator .check_addr (src , & src_dev , & flags );
106
+ if (0 >= dst_type && 0 >= src_type ) {
97
107
return memmove (dest , src , size );
98
108
}
99
- res = opal_accelerator .mem_move (MCA_ACCELERATOR_NO_DEVICE_ID , MCA_ACCELERATOR_NO_DEVICE_ID ,
100
- dest , src , size , MCA_ACCELERATOR_TRANSFER_UNSPEC );
109
+ else if (0 >= dst_type && 0 < src_type ) {
110
+ copy_type = MCA_ACCELERATOR_TRANSFER_DTOH ;
111
+ }
112
+ else if (0 < dst_type && 0 >= dst_type ) {
113
+ copy_type = MCA_ACCELERATOR_TRANSFER_HTOD ;
114
+ }
115
+ res = opal_accelerator .mem_move (dst_dev , src_dev ,
116
+ dest , src , size , copy_type );
101
117
if (OPAL_SUCCESS != res ) {
102
118
opal_output (0 , "Error in accelerator memmove" );
103
119
abort ();
0 commit comments