📄 mpidu_sock.h
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//* * (C) 2001 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */#if !defined(MPIDU_SOCK_H_INCLUDED)#define MPIDU_SOCK_H_INCLUDED#if defined(__cplusplus)#if !defined(CPLUSPLUS_BEGIN)#define CPLUSPLUS_BEGIN extern "C" {#define CPLUSPLUS_END }#endif#else#define CPLUSPLUS_BEGIN#define CPLUSPLUS_END#endifCPLUSPLUS_BEGIN/* config header file */#include "mpidu_sock_conf.h"#include "mpitypedefs.h"/* implemenatation specific header file */ #include "mpidu_socki.h"/*DMPIDU_SOCK_ERR - Extended error classes specific to the Sock moduleNotes:The actual meaning of these error classes is defined by each function. Module:Utility-SockD*/#define MPIDU_SOCK_SUCCESS MPI_SUCCESS#define MPIDU_SOCK_ERR_FAIL MPICH_ERR_LAST_CLASS + 1#define MPIDU_SOCK_ERR_INIT MPICH_ERR_LAST_CLASS + 2#define MPIDU_SOCK_ERR_NOMEM MPICH_ERR_LAST_CLASS + 3#define MPIDU_SOCK_ERR_BAD_SET MPICH_ERR_LAST_CLASS + 4#define MPIDU_SOCK_ERR_BAD_SOCK MPICH_ERR_LAST_CLASS + 5#define MPIDU_SOCK_ERR_BAD_HOST MPICH_ERR_LAST_CLASS + 6#define MPIDU_SOCK_ERR_BAD_HOSTNAME MPICH_ERR_LAST_CLASS + 7#define MPIDU_SOCK_ERR_BAD_PORT MPICH_ERR_LAST_CLASS + 8#define MPIDU_SOCK_ERR_BAD_BUF MPICH_ERR_LAST_CLASS + 9#define MPIDU_SOCK_ERR_BAD_LEN MPICH_ERR_LAST_CLASS + 10#define MPIDU_SOCK_ERR_SOCK_CLOSED MPICH_ERR_LAST_CLASS + 11#define MPIDU_SOCK_ERR_CONN_CLOSED MPICH_ERR_LAST_CLASS + 12#define MPIDU_SOCK_ERR_CONN_FAILED MPICH_ERR_LAST_CLASS + 13#define MPIDU_SOCK_ERR_INPROGRESS MPICH_ERR_LAST_CLASS + 14#define MPIDU_SOCK_ERR_TIMEOUT MPICH_ERR_LAST_CLASS + 15#define MPIDU_SOCK_ERR_INTR MPICH_ERR_LAST_CLASS + 16#define MPIDU_SOCK_ERR_NO_NEW_SOCK MPICH_ERR_LAST_CLASS + 17/*EMPIDU_Sock_op_t - enumeration of posted operations that can be completed by the Sock moduleNotes:MPIDU_SOCK_OP_ACCEPT is different that the other operations. When returned by MPIDU_Sock_wait(), operations other thanMPIDU_SOCK_OP_ACCEPT mark the completion of a previously posted operation. MPIDU_SOCK_OP_ACCEPT indicates that a new connection isbeing formed and that MPIDU_Sock_accept() should be called.Module:Utility-SockE*/typedef enum MPIDU_Sock_op{ MPIDU_SOCK_OP_READ, MPIDU_SOCK_OP_WRITE, MPIDU_SOCK_OP_ACCEPT, MPIDU_SOCK_OP_CONNECT, MPIDU_SOCK_OP_CLOSE, MPIDU_SOCK_OP_WAKEUP} MPIDU_Sock_op_t;/*SMPIDU_Sock_event_t - event structure returned by MPIDU_Sock_wait() describing the operation that completedFields:+ op_type - type of operation that completed. num_bytes - number of bytes transferred (if appropriate). user_ptr - user pointer associated with the sock on which this operation completed- error - a MPI error code with a Sock extended error classNotes:The num_bytes field is only used when a posted read or write operation completes.Module:Utility-SockS*/typedef struct MPIDU_Sock_event{ MPIDU_Sock_op_t op_type; MPIU_Size_t num_bytes; void * user_ptr; int error;} MPIDU_Sock_event_t;/*@MPIDU_Sock_init - initialize the Sock communication libraryReturn value: a MPI error code with a Sock extended error class+ MPI_SUCCESS - initialization completed successfully. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory- MPIDU_SOCK_ERR_FAIL - other failure; initialization failedNotes:The Sock module may be initialized multiple times. The implementation should perform reference counting if necessary.Module:Utility-Sock@*/int MPIDU_Sock_init(void);/*@MPIDU_Sock_finalize - shutdown the Sock communication libraryReturn value: a MPI error code with a Sock extended error class+ MPI_SUCCESS - shutdown completed successfully. MPIDU_SOCK_ERR_INIT - Sock module not initialized. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory- MPIDU_SOCK_ERR_FAIL - other failure; shutdown failedNotes:<BRT> What are the semantics of finalize? Is it responsible for releasing any resources (socks and sock sets) that the callingcode(s) leaked? Should it block until all OS resources are released?Module:Utility-Sock@*/int MPIDU_Sock_finalize(void);/*@MPIDU_Sock_get_host_description - obtain a description of the host's communication capabilitiesInput Parameters:+ host_description - character array in which the function can store a string describing the communication capabilities of the host- len - length of the character arrayReturn value: a MPI error code with a Sock extended error class+ MPI_SUCCESS - description successfully obtained and placed in host_description. MPIDU_SOCK_ERR_INIT - Sock module not initialized. MPIDU_SOCK_ERR_BAD_LEN - len parameter is less than zero. MPIDU_SOCK_ERR_BAD_HOST - host_description parameter not big enough to store required information. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory- MPIDU_SOCK_ERR_FAIL - unable to obtain network interface information from OSNotes:The host description string returned by the function is defined by the implementation and should not be interpreted by theapplication. This string is to be supplied to MPIDU_Sock_post_connect() when one wishes to form a connection with this host.Module:Utility-Sock@*/int MPIDU_Sock_get_host_description(char * host_description, int len);/*@MPIDU_Sock_hostname_to_host_description - convert a host name to a description of the host's communication capabilitiesInput Parameters:+ hostname - host name string. host_description - character array in which the function can store a string describing the communication capabilities of the host- len - length of host_descriptionReturn value: a MPI error code with a Sock extended error class+ MPI_SUCCESS - description successfully obtained and placed in host_description. MPIDU_SOCK_ERR_INIT - Sock module not initialized. MPIDU_SOCK_ERR_BAD_LEN - len parameter is less than zero. MPIDU_SOCK_ERR_BAD_HOSTNAME - hostname parameter not valid. MPIDU_SOCK_ERR_BAD_HOST - host_description parameter not big enough to store required information. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory- MPIDU_SOCK_ERR_FAIL - unable to obtain network interface information from OSNotes:The host description string returned by the function is defined by the implementation and should not be interpreted by theapplication. This string is to be supplied to MPIDU_Sock_post_connect() when one wishes to form a connection with the hostspecified by hostname.Module:Utility-Sock@*/int MPIDU_Sock_hostname_to_host_description(char *hostname, char * host_description, int len);/*@MPIDU_Sock_create_set - create a new sock set objectOutput Parameter:. set - pointer to the new sock set objectReturn value: a MPI error code with a Sock extended error class+ MPI_SUCCESS - new sock set successfully create. MPIDU_SOCK_ERR_INIT - Sock module not initialized. MPIDU_SOCK_ERR_BAD_SET - pointer to the sock set object is bad. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory- MPIDU_SOCK_ERR_FAIL - other failureNotes:A sock set contains zero or more sock objects. Each sock object belongs to a single sock set and is bound to that set for the lifeof that object.Module:Utility-Sock@*/int MPIDU_Sock_create_set(MPIDU_Sock_set_t * set);/*@MPIDU_Sock_destroy_set - destroy an existing sock set, releasing an internal resource associated with that setInput Parameter:. set - set to be destroyedReturn value: a MPI error code with a Sock extended error class+ MPI_SUCCESS - sock set successfully destroyed. MPIDU_SOCK_ERR_INIT - Sock module not initialized. MPIDU_SOCK_ERR_BAD_SET - invalid sock set. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory- MPIDU_SOCK_ERR_FAIL - unable to destroy the sock set (<BRT> because it still contained active sock objects?)Notes:<BRT> What are the semantics for destroying a sock set that still contains active sock objects? sock objects by definitioncannot exist outside of a set.It is consider erroneous to destroy a set that still contains sock objects or is being operated upon with an of the Sock routines.Module:Utility-Sock@*/int MPIDU_Sock_destroy_set(MPIDU_Sock_set_t set);/*@MPIDU_Sock_native_to_sock - convert a native file descriptor/handle to a sock objectInput Parameters:+ set - sock set to which the new sock should be added. fd - native file descriptor- user_ptr - user pointer to be associated with the new sockOutput Parameter:. sock - new sock objectReturn value: a MPI error code with a Sock extended error class+ MPI_SUCCESS - sock successfully created. MPIDU_SOCK_ERR_INIT - Sock module not initialized. MPIDU_SOCK_ERR_BAD_SET - invalid sock set. MPIDU_SOCK_ERR_BAD_NATIVE_FD - invalid native file descriptor. MPIDU_SOCK_ERR_NOMEM - unable to allocate required memory- MPIDU_SOCK_ERR_FAIL - other failure; listener sock could not be createdNotes:The constraints on which file descriptors/handles may be converted to a sock object are defined by the implementation. Theimplementation may return MPIDU_SOCK_ERR_BAD_NATIVE_FD if the descriptor/handle cannot be used with the implementation. It ispossible, however, that the conversion of an inappropriate descriptor/handle may complete successfully but the sock object may notfunction properly.Thread safety:The addition of a new sock object to the sock set may occur while other threads are performing operations on the same sock set.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -