1 /* 2 * Copyright (C) by Argonne National Laboratory 3 * See COPYRIGHT in top-level directory 4 */ 5 6 #ifndef YAKSUR_PRE_H_INCLUDED 7 #define YAKSUR_PRE_H_INCLUDED 8 9 /* This is a API header exposed by the backend glue layer. It should 10 * not include any internal headers except: (1) yaksa_config.h, in 11 * order to get the configure checks; and (2) API headers for the 12 * devices (e.g., yaksuri_seq.h) */ 13 #include <stdint.h> 14 #include "yaksuri_seq_pre.h" 15 #include "yaksuri_cuda_pre.h" 16 #include "yaksuri_ze_pre.h" 17 18 typedef struct { 19 enum { 20 YAKSUR_PTR_TYPE__UNREGISTERED_HOST, 21 YAKSUR_PTR_TYPE__REGISTERED_HOST, 22 YAKSUR_PTR_TYPE__GPU, 23 YAKSUR_PTR_TYPE__MANAGED, 24 } type; 25 int device; 26 } yaksur_ptr_attr_s; 27 28 struct yaksi_type_s; 29 struct yaksi_info_s; 30 31 typedef struct yaksur_type_s { 32 yaksuri_seq_type_s seq; 33 yaksuri_cuda_type_s cuda; 34 yaksuri_ze_type_s ze; 35 } yaksur_type_s; 36 37 typedef struct { 38 yaksur_ptr_attr_s inattr; 39 yaksur_ptr_attr_s outattr; 40 void *priv; 41 } yaksur_request_s; 42 43 typedef struct { 44 bool pre_init; /* set to true for info created before yaksa_init */ 45 yaksuri_seq_info_s seq; 46 yaksuri_cuda_info_s cuda; 47 yaksuri_ze_info_s ze; 48 void *priv; 49 } yaksur_info_s; 50 51 typedef struct yaksur_gpudriver_hooks_s { 52 /* miscellaneous */ 53 int (*get_num_devices) (int *ndevices); 54 int (*check_p2p_comm) (int sdev, int ddev, bool * is_enabled); 55 int (*finalize) (void); 56 57 /* pup functions */ 58 /* *INDENT-OFF* */ 59 uintptr_t (*get_iov_pack_threshold) (struct yaksi_info_s * info); 60 uintptr_t (*get_iov_unpack_threshold) (struct yaksi_info_s * info); 61 /* *INDENT-ON* */ 62 int (*ipack) (const void *inbuf, void *outbuf, uintptr_t count, 63 struct yaksi_type_s * type, struct yaksi_info_s * info, int device); 64 int (*iunpack) (const void *inbuf, void *outbuf, uintptr_t count, struct yaksi_type_s * type, 65 struct yaksi_info_s * info, int device); 66 int (*pup_is_supported) (struct yaksi_type_s * type, bool * is_supported); 67 68 /* memory management */ 69 void *(*host_malloc) (uintptr_t size); 70 void (*host_free) (void *ptr); 71 void *(*gpu_malloc) (uintptr_t size, int device); 72 void (*gpu_free) (void *ptr); 73 int (*get_ptr_attr) (const void *inbuf, void *outbuf, struct yaksi_info_s * info, 74 yaksur_ptr_attr_s * inattr, yaksur_ptr_attr_s * outattr); 75 76 /* events */ 77 int (*event_record) (int device, void **event); 78 int (*event_query) (void *event, int *completed); 79 int (*add_dependency) (int device1, int device2); 80 81 /* types */ 82 int (*type_create) (struct yaksi_type_s * type); 83 int (*type_free) (struct yaksi_type_s * type); 84 85 /* info */ 86 int (*info_create) (struct yaksi_info_s * info); 87 int (*info_free) (struct yaksi_info_s * info); 88 int (*info_keyval_append) (struct yaksi_info_s * info, const char *key, const void *val, 89 unsigned int vallen); 90 } yaksur_gpudriver_hooks_s; 91 92 #endif /* YAKSUR_PRE_H_INCLUDED */ 93