|
4 | 4 | * reserved.
|
5 | 5 | * Copyright (c) 2019-2024 Triad National Security, LLC. All rights
|
6 | 6 | * reserved.
|
7 |
| - * Copyright (c) 2018-2023 Amazon.com, Inc. or its affiliates. All Rights reserved. |
8 |
| - * reserved. |
| 7 | + * Copyright (c) 2018-2025 Amazon.com, Inc. or its affiliates. All Rights reserved. |
9 | 8 | * Copyright (c) 2021 Cisco Systems, Inc. All rights reserved
|
10 | 9 | * Copyright (c) 2021 The University of Tennessee and The University
|
11 | 10 | * of Tennessee Research Foundation. All rights
|
@@ -73,6 +72,8 @@ extern int ompi_mtl_ofi_del_comm(struct mca_mtl_base_module_t *mtl,
|
73 | 72 |
|
74 | 73 | int ompi_mtl_ofi_progress_no_inline(void);
|
75 | 74 |
|
| 75 | +int ompi_mtl_ofi_rcache_init(void); |
| 76 | + |
76 | 77 | #if OPAL_HAVE_THREAD_LOCAL
|
77 | 78 | extern opal_thread_local int ompi_mtl_ofi_per_thread_ctx;
|
78 | 79 | #endif
|
@@ -291,73 +292,37 @@ ompi_mtl_ofi_set_mr_null(ompi_mtl_ofi_request_t *ofi_req) {
|
291 | 292 | static
|
292 | 293 | int ompi_mtl_ofi_register_buffer(struct opal_convertor_t *convertor,
|
293 | 294 | ompi_mtl_ofi_request_t *ofi_req,
|
294 |
| - void* buffer) { |
| 295 | + void* buffer) |
| 296 | +{ |
| 297 | + int ret; |
| 298 | + uint32_t cache_flags = 0; |
| 299 | + |
295 | 300 | ofi_req->mr = NULL;
|
296 | 301 | if (ofi_req->length <= 0 || NULL == buffer) {
|
297 | 302 | return OMPI_SUCCESS;
|
298 | 303 | }
|
299 | 304 |
|
300 |
| -#if OPAL_OFI_HAVE_FI_MR_IFACE |
301 |
| - |
302 |
| - if ((convertor->flags & CONVERTOR_ACCELERATOR) && ompi_mtl_ofi.hmem_needs_reg) { |
303 |
| - /* Register buffer */ |
304 |
| - int ret; |
305 |
| - struct fi_mr_attr attr = {0}; |
306 |
| - struct iovec iov = {0}; |
307 |
| - |
308 |
| - iov.iov_base = buffer; |
309 |
| - iov.iov_len = ofi_req->length; |
310 |
| - attr.mr_iov = &iov; |
311 |
| - attr.iov_count = 1; |
312 |
| - attr.access = FI_SEND | FI_RECV; |
313 |
| - attr.offset = 0; |
314 |
| - attr.context = NULL; |
315 |
| - if (false == ompi_mtl_base_selected_component->accelerator_support) { |
316 |
| - goto reg; |
317 |
| - } else if (0 == strcmp(opal_accelerator_base_selected_component.base_version.mca_component_name, "cuda")) { |
318 |
| - attr.iface = FI_HMEM_CUDA; |
319 |
| - opal_accelerator.get_device(&attr.device.cuda); |
320 |
| -#if OPAL_OFI_HAVE_FI_HMEM_ROCR |
321 |
| - } else if (0 == strcmp(opal_accelerator_base_selected_component.base_version.mca_component_name, "rocm")) { |
322 |
| - attr.iface = FI_HMEM_ROCR; |
323 |
| - opal_accelerator.get_device(&attr.device.cuda); |
324 |
| -#endif |
325 |
| - } else { |
326 |
| - return OPAL_ERROR; |
327 |
| - } |
328 |
| -reg: |
329 |
| - ret = fi_mr_regattr(ompi_mtl_ofi.domain, &attr, 0, &ofi_req->mr); |
330 |
| - |
331 |
| - if (ret) { |
332 |
| - opal_show_help("help-mtl-ofi.txt", "Buffer Memory Registration Failed", true, |
333 |
| - opal_accelerator_base_selected_component.base_version.mca_component_name, |
334 |
| - buffer, ofi_req->length, |
335 |
| - fi_strerror(-ret), ret); |
336 |
| - ofi_req->mr = NULL; |
337 |
| - return OMPI_ERROR; |
338 |
| - } |
| 305 | + if (! ((convertor->flags & CONVERTOR_ACCELERATOR) && ompi_mtl_ofi.hmem_needs_reg)) { |
| 306 | + return OMPI_SUCCESS; |
339 | 307 | }
|
340 | 308 |
|
341 |
| -#endif |
342 |
| - |
343 |
| - return OMPI_SUCCESS; |
| 309 | + /* note - the cache access flags are a little broken, because rcache doesn't |
| 310 | + * understand send/recv requirements. Since this rcache is only used in the |
| 311 | + * MTL, that isn't a problem and we fix it in the underlying register call. |
| 312 | + */ |
| 313 | + ret = ompi_mtl_ofi.rcache->rcache_register(ompi_mtl_ofi.rcache, buffer, ofi_req->length, |
| 314 | + cache_flags, MCA_RCACHE_ACCESS_ANY, |
| 315 | + (mca_rcache_base_registration_t **) &ofi_req->mr); |
| 316 | + return ret; |
344 | 317 | }
|
345 | 318 |
|
346 | 319 | /** Deregister buffer */
|
347 | 320 | __opal_attribute_always_inline__ static inline int
|
348 | 321 | ompi_mtl_ofi_deregister_buffer(ompi_mtl_ofi_request_t *ofi_req) {
|
349 | 322 | if (ofi_req->mr) {
|
350 |
| - int ret; |
351 |
| - ret = fi_close(&ofi_req->mr->fid); |
352 |
| - if (ret) { |
353 |
| - opal_show_help("help-mtl-ofi.txt", "OFI call fail", true, |
354 |
| - "fi_close", |
355 |
| - ompi_process_info.nodename, __FILE__, __LINE__, |
356 |
| - fi_strerror(-ret), ofi_req->mr->fid); |
357 |
| - return OMPI_ERROR; |
358 |
| - } |
359 |
| - ofi_req->mr = NULL; |
| 323 | + (void)ompi_mtl_ofi.rcache->rcache_deregister(ompi_mtl_ofi.rcache, &ofi_req->mr->base); |
360 | 324 | }
|
| 325 | + |
361 | 326 | return OMPI_SUCCESS;
|
362 | 327 | }
|
363 | 328 |
|
|
0 commit comments