root/opal/mca/common/cuda/common_cuda.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. opal_convertor_cuda_need_buffers

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2013 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2006 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2011-2015 NVIDIA Corporation.  All rights reserved.
  14  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
  15  *                         reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #ifndef OPAL_MCA_COMMON_CUDA_H
  24 #define OPAL_MCA_COMMON_CUDA_H
  25 #include "opal/mca/btl/btl.h"
  26 #include "opal/datatype/opal_convertor.h"
  27 
  28 #define MEMHANDLE_SIZE 8
  29 #define EVTHANDLE_SIZE 8
  30 
  31 struct mca_rcache_common_cuda_reg_data_t {
  32     uint64_t memHandle[MEMHANDLE_SIZE];
  33     uint64_t evtHandle[EVTHANDLE_SIZE];
  34     uint64_t event;
  35     opal_ptr_t memh_seg_addr;
  36     size_t memh_seg_len;
  37 };
  38 typedef struct mca_rcache_common_cuda_reg_data_t mca_rcache_common_cuda_reg_data_t;
  39 
  40 struct mca_rcache_common_cuda_reg_t {
  41     mca_rcache_base_registration_t base;
  42     mca_rcache_common_cuda_reg_data_t data;
  43 };
  44 typedef struct mca_rcache_common_cuda_reg_t mca_rcache_common_cuda_reg_t;
  45 extern bool mca_common_cuda_enabled;
  46 
  47 OPAL_DECLSPEC void mca_common_cuda_register_mca_variables(void);
  48 
  49 OPAL_DECLSPEC void mca_common_cuda_register(void *ptr, size_t amount, char *msg);
  50 
  51 OPAL_DECLSPEC void mca_common_cuda_unregister(void *ptr, char *msg);
  52 
  53 OPAL_DECLSPEC void mca_common_wait_stream_synchronize(mca_rcache_common_cuda_reg_t *rget_reg);
  54 
  55 OPAL_DECLSPEC int mca_common_cuda_memcpy(void *dst, void *src, size_t amount, char *msg,
  56                                          struct mca_btl_base_descriptor_t *, int *done);
  57 
  58 OPAL_DECLSPEC int mca_common_cuda_record_ipc_event(char *msg,
  59                                                struct mca_btl_base_descriptor_t *frag);
  60 OPAL_DECLSPEC int mca_common_cuda_record_dtoh_event(char *msg,
  61                                                     struct mca_btl_base_descriptor_t *frag);
  62 OPAL_DECLSPEC int mca_common_cuda_record_htod_event(char *msg,
  63                                                     struct mca_btl_base_descriptor_t *frag);
  64 
  65 OPAL_DECLSPEC void *mca_common_cuda_get_dtoh_stream(void);
  66 OPAL_DECLSPEC void *mca_common_cuda_get_htod_stream(void);
  67 
  68 OPAL_DECLSPEC int progress_one_cuda_ipc_event(struct mca_btl_base_descriptor_t **);
  69 OPAL_DECLSPEC int progress_one_cuda_dtoh_event(struct mca_btl_base_descriptor_t **);
  70 OPAL_DECLSPEC int progress_one_cuda_htod_event(struct mca_btl_base_descriptor_t **);
  71 
  72 OPAL_DECLSPEC int mca_common_cuda_memhandle_matches(mca_rcache_common_cuda_reg_t *new_reg,
  73                                                     mca_rcache_common_cuda_reg_t *old_reg);
  74 
  75 OPAL_DECLSPEC void mca_common_cuda_construct_event_and_handle(uintptr_t *event, void *handle);
  76 OPAL_DECLSPEC void mca_common_cuda_destruct_event(uintptr_t event);
  77 
  78 OPAL_DECLSPEC int cuda_getmemhandle(void *base, size_t, mca_rcache_base_registration_t *newreg,
  79                                     mca_rcache_base_registration_t *hdrreg);
  80 OPAL_DECLSPEC int cuda_ungetmemhandle(void *reg_data, mca_rcache_base_registration_t *reg);
  81 OPAL_DECLSPEC int cuda_openmemhandle(void *base, size_t size, mca_rcache_base_registration_t *newreg,
  82                                      mca_rcache_base_registration_t *hdrreg);
  83 OPAL_DECLSPEC int cuda_closememhandle(void *reg_data, mca_rcache_base_registration_t *reg);
  84 OPAL_DECLSPEC int mca_common_cuda_get_device(int *devicenum);
  85 OPAL_DECLSPEC int mca_common_cuda_device_can_access_peer(int *access, int dev1, int dev2);
  86 OPAL_DECLSPEC int mca_common_cuda_stage_one_init(void);
  87 OPAL_DECLSPEC int mca_common_cuda_get_address_range(void *pbase, size_t *psize, void *base);
  88 OPAL_DECLSPEC void mca_common_cuda_fini(void);
  89 #if OPAL_CUDA_GDR_SUPPORT
  90 OPAL_DECLSPEC bool mca_common_cuda_previously_freed_memory(mca_rcache_base_registration_t *reg);
  91 OPAL_DECLSPEC void mca_common_cuda_get_buffer_id(mca_rcache_base_registration_t *reg);
  92 #endif /* OPAL_CUDA_GDR_SUPPORT */
  93 /**
  94  * Return:   0 if no packing is required for sending (the upper layer
  95  *             can use directly the pointer to the contiguous user
  96  *             buffer).
  97  *           1 if data does need to be packed, i.e. heterogeneous peers
  98  *             (source arch != dest arch) or non contiguous memory
  99  *             layout.
 100  */
 101 static inline int32_t opal_convertor_cuda_need_buffers( opal_convertor_t* pConvertor )
 102 {
 103     int32_t retval;
 104     uint32_t cudaflag = pConvertor->flags & CONVERTOR_CUDA; /* Save CUDA flag */
 105     pConvertor->flags &= ~CONVERTOR_CUDA;              /* Clear CUDA flag if it exists */
 106     retval = opal_convertor_need_buffers(pConvertor);
 107     pConvertor->flags |= cudaflag; /* Restore CUDA flag */
 108     return retval;
 109 }
 110 
 111 #endif /* OPAL_MCA_COMMON_CUDA_H */

/* [<][>][^][v][top][bottom][index][help] */