Skip to content

Commit 0037610

Browse files
authored
Merge pull request #46 from 23-Wzz/huawei
Delete Chenge's MR
2 parents 532e73b + b4f9079 commit 0037610

26 files changed

+2026
-2511
lines changed

Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ nobase_dist_libucg_la_HEADERS = \
2626
api/ucg_mpi.h \
2727
api/ucg.h
2828

29+
noinst_HEADERS = \
30+
api/ucg_plan_component.h
31+
2932
endif # HAVE_UCG

api/ucg.h

Lines changed: 85 additions & 233 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,36 @@
2020

2121
BEGIN_C_DECLS
2222

23+
/**
24+
* @defgroup UCG_API Unified Communication Protocol (UCG) API
25+
* @{
26+
* This section describes UCG API.
27+
* @}
28+
*/
29+
#define ucg_context_h ucp_context_h
30+
#define ucg_config_t ucp_config_t
31+
#define ucg_address_t ucp_address_t
32+
#define ucg_worker_h ucp_worker_h
33+
#define ucg_params_t ucp_params_t
34+
#define ucg_context_attr_t ucp_context_attr_t
35+
#define ucg_worker_attr_t ucp_worker_attr_t
36+
#define ucg_worker_params_t ucp_worker_params_t
37+
38+
#define ucg_config_read ucp_config_read
39+
#define ucg_config_release ucp_config_release
40+
#define ucg_config_modify ucp_config_modify
41+
#define ucg_config_print ucp_config_print
42+
#define ucg_get_version ucp_get_version
43+
#define ucg_get_version_string ucp_get_version_string
44+
#define ucg_cleanup ucp_cleanup
45+
#define ucg_context_query ucp_context_query
46+
#define ucg_context_print_info ucp_context_print_info
47+
#define ucg_worker_destroy ucp_worker_destroy
48+
#define ucg_worker_query ucp_worker_query
49+
#define ucg_worker_print_info ucp_worker_print_info
50+
#define ucg_worker_get_address ucp_worker_get_address
51+
#define ucg_worker_release_address ucp_worker_release_address
52+
2353
/**
2454
* @ingroup UCG_GROUP
2555
* @brief UCG group collective operation description.
@@ -72,94 +102,12 @@ enum UCS_S_PACKED ucg_group_hierarchy_level {
72102
UCG_GROUP_HIERARCHY_LEVEL_L3CACHE
73103
};
74104

75-
76-
/**
77-
* @ingroup UCG_CONTEXT
78-
* @brief UCG context parameters field mask.
79-
*
80-
* The enumeration allows specifying which fields in @ref ucg_params_t are
81-
* present. It is used to enable backward compatibility support.
82-
*/
83-
enum ucg_params_field {
84-
UCG_PARAM_FIELD_ADDRESS_CB = UCS_BIT(0), /**< Peer address lookup */
85-
UCG_PARAM_FIELD_REDUCE_CB = UCS_BIT(1), /**< Callback for reduce ops */
86-
UCG_PARAM_FIELD_COMMUTE_CB = UCS_BIT(2), /**< Callback for check op communative */
87-
UCG_PARAM_FIELD_GLOBALIDX_CB = UCS_BIT(3),
88-
UCG_PARAM_FIELD_DTCONVERT_CB = UCS_BIT(4),
89-
UCG_PARAM_FIELD_DATATYPESPAN_CB = UCS_BIT(5),
90-
UCG_PARAM_FIELD_MPI_IN_PLACE = UCS_BIT(6), /**< MPI_IN_PLACE value */
91-
};
92-
93-
/**
94-
* @ingroup UCG_CONTEXT
95-
* @brief Creation parameters for the UCG context.
96-
*
97-
* The structure defines the parameters that are used during the UCG
98-
* initialization by @ref ucg_init .
99-
*/
100-
typedef struct ucg_params {
101-
/**
102-
* Mask of valid fields in this structure, using bits from @ref ucg_params_field.
103-
* Fields not specified in this mask will be ignored.
104-
* Provides ABI compatibility with respect to adding new fields.
105-
*/
106-
uint64_t field_mask;
107-
108-
/* Callback functions for address lookup, used at connection establishment */
109-
struct {
110-
ucg_addr_lookup_callback_t lookup_f;
111-
ucg_addr_release_callback_t release_f;
112-
} address;
113-
114-
/* Callback function for mpi reduce */
115-
ucg_mpi_reduce_callback_t mpi_reduce_f;
116-
117-
/* Callback function for checking op communative */
118-
ucg_mpi_op_is_commute_callback_t op_is_commute_f;
119-
120-
/* Callback function for rank in MPI_COMM_WORLD */
121-
mpi_global_idx_t mpi_global_idx_f;
122-
123-
/* Callback function for MPI datatype convert function */
124-
dt_convert_t mpi_dt_convert;
125-
126-
/* Callback function for reduce buffer */
127-
dt_span_t mpi_datatype_span;
128-
129-
/* The value of MPI_IN_PLACE */
130-
void *mpi_in_place;
131-
} ucg_params_t;
132-
133-
enum ucg_group_params_field {
134-
UCG_GROUP_PARAM_FIELD_UCP_WORKER = UCS_BIT(0),
135-
UCG_GROUP_PARAM_FIELD_ID = UCS_BIT(1),
136-
UCG_GROUP_PARAM_FIELD_MEMBER_COUNT = UCS_BIT(2),
137-
UCG_GROUP_PARAM_FIELD_TOPO_MAP = UCS_BIT(3),
138-
UCG_GROUP_PARAM_FIELD_DISTANCE = UCS_BIT(4),
139-
UCG_GROUP_PARAM_FIELD_NODE_INDEX = UCS_BIT(5),
140-
UCG_GROUP_PARAM_FIELD_BIND_TO_NONE = UCS_BIT(6),
141-
UCG_GROUP_PARAM_FIELD_CB_GROUP_IBJ = UCS_BIT(7),
142-
UCG_GROUP_PARAM_FIELD_MPI_DT_CONVERT = UCS_BIT(8),
143-
UCG_GROUP_PARAM_FIELD_MPI_DATATYPE_SPAN = UCS_BIT(9),
144-
UCG_GROUP_PARAM_FIELD_IS_SOCKET_BALANCE = UCS_BIT(10),
145-
};
105+
typedef int (*dt_convert_f)(void *dt_ext, ucp_datatype_t *ucp_datatype);
106+
typedef ptrdiff_t (*dt_span_f)(void *dt_ext, int count, ptrdiff_t *gap);
146107

147108
typedef struct ucg_group_params {
148-
/**
149-
* Mask of valid fields in this structure, using bits from @ref ucg_group_params_field.
150-
* Fields not specified in this mask will be ignored.
151-
* Provides ABI compatibility with respect to adding new fields.
152-
*/
153-
uint64_t field_mask;
154-
155-
/* UCP worker to create a ucg group on top of */
156-
ucp_worker_h ucp_worker;
157-
158-
/* Unique group identifier */
159-
uint32_t group_id;
160-
161-
/* number of group members */
162-
int member_count;
109+
ucg_group_member_index_t member_count; /* number of group members */
110+
uint32_t cid; /* Assign value to group_id */
163111

164112
char **topo_map; /* Global topology map, topo_map[i][j] means Distance between rank i and rank j. */
165113

@@ -191,8 +139,25 @@ typedef struct ucg_group_params {
191139
/* bind-to none flag */
192140
unsigned is_bind_to_none;
193141

194-
/* external group object for call-backs (MPI_Comm) */
195-
void *cb_group_obj;
142+
/* MPI passes its own reduction function, used for complex data-types */
143+
void (*mpi_reduce_f)(void *mpi_op, char *src, char *dst, unsigned count, void *mpi_dtype);
144+
145+
/* Callback function for connection establishment */
146+
ucs_status_t (*resolve_address_f)(void *cb_group_obj, ucg_group_member_index_t index,
147+
ucg_address_t **addr, size_t *addr_len);
148+
void (*release_address_f)(ucg_address_t *addr);
149+
150+
void *cb_group_obj; /* external group object for call-backs (MPI_Comm) */
151+
152+
/* Callback function for MPI_OP */
153+
int (*op_is_commute_f)(void *mpi_op);
154+
155+
dt_convert_f mpi_dt_convert;
156+
157+
/* Callback function for get rank in MPI_COMM_WORLD */
158+
ucg_group_member_index_t (*mpi_global_idx_f) (void *cb_group_obj, ucg_group_member_index_t index);
159+
160+
dt_span_f mpi_datatype_span;
196161
char is_socket_balance;
197162
} ucg_group_params_t;
198163

@@ -224,44 +189,6 @@ typedef struct ucg_collective {
224189

225190
} ucg_collective_params_t;
226191

227-
/** @cond PRIVATE_INTERFACE */
228-
/**
229-
* @ingroup UCG_CONTEXT
230-
* @brief UCG context initialization with particular API version
231-
*
232-
* This is an internal routine used to check compatibility with a paticular
233-
* API version. @ref ucg_init should be used to create UCG context
234-
*/
235-
ucs_status_t ucg_init_version(unsigned api_major_version,
236-
unsigned api_minor_version,
237-
const ucg_params_t *params,
238-
const ucg_config_t *config,
239-
ucg_context_h *ctx_p);
240-
/** @endcond */
241-
242-
/**
243-
* @ingroup UCG_CONTEXT
244-
* @brief UCG context initialization.
245-
* @warning This routine must be called before any other UCG function
246-
* call in the application.
247-
*/
248-
ucs_status_t ucg_init(const ucg_params_t *params,
249-
const ucg_config_t *config,
250-
ucg_context_h *ctx_p);
251-
252-
253-
/**
254-
* @ingroup UCG_CONTEXT
255-
* @brief Release UCG application context.
256-
*
257-
* This routine finalizes and releases the resources associated with a
258-
* @ref ucg_context_h "UCG application context".
259-
*
260-
* @warning An application cannot call any UCG routine
261-
* once the UCG application context released.
262-
*/
263-
void ucg_cleanup(ucg_context_h ctx_p);
264-
265192

266193
/**
267194
* @ingroup UCG_GROUP
@@ -275,15 +202,15 @@ void ucg_cleanup(ucg_context_h ctx_p);
275202
*
276203
* @note The group object is allocated within context of the calling thread
277204
*
278-
* @param [in] context Handle to @ref ucg_context_h
205+
* @param [in] worker Worker to create a group on top of.
279206
* @param [in] params User defined @ref ucg_group_params_t configurations for the
280207
* @ref ucg_group_h "UCG group".
281208
* @param [out] group_p A pointer to the group object allocated by the
282209
* UCG library
283210
*
284211
* @return Error code as defined by @ref ucs_status_t
285212
*/
286-
ucs_status_t ucg_group_create(ucg_context_h context,
213+
ucs_status_t ucg_group_create(ucg_worker_h worker,
287214
const ucg_group_params_t *params,
288215
ucg_group_h *group_p);
289216

@@ -317,6 +244,24 @@ void ucg_group_destroy(ucg_group_h group);
317244
unsigned ucg_group_progress(ucg_group_h group);
318245

319246

247+
/**
248+
* @ingroup UCG_GROUP
249+
* @brief Progresses a Worker object with the groups (UCG) extension.
250+
*
251+
* @param [in] group Group object to progress.
252+
*/
253+
unsigned ucg_worker_progress(ucg_worker_h worker);
254+
255+
256+
/**
257+
* @ingroup UCG_GROUP
258+
* @brief Exposes the parameters used to create the Group object.
259+
*
260+
* @param [in] group Group object to query.
261+
*/
262+
const ucg_group_params_t* ucg_group_get_params(ucg_group_h group);
263+
264+
320265
/**
321266
* @ingroup UCG_GROUP
322267
* @brief Creates a collective operation on a group object.
@@ -401,117 +346,24 @@ void ucg_collective_destroy(ucg_coll_h coll);
401346
*/
402347
ucs_status_t ucg_request_check_status(void *request);
403348

404-
/**
405-
* @ingroup UCG_GROUP
406-
* @brief Cancel the non-blocking request.
407-
*/
408-
void ucg_request_cancel(ucg_group_h group, void *request);
349+
void ucg_request_cancel(ucg_worker_h worker, void *request);
409350

410-
/**
411-
* @ingroup UCG_GROUP
412-
* @brief free the non-blocking request.
413-
*/
414351
void ucg_request_free(void *request);
415352

416353

417-
/**
418-
* @ingroup UCG_CONFIG
419-
* @brief Read UCG configuration descriptor
420-
*
421-
* The routine fetches the information about UCG library configuration from
422-
* the run-time environment. Then, the fetched descriptor is used for
423-
* UCG library @ref ucg_init "initialization". The Application can print out the
424-
* descriptor using @ref ucg_config_print "print" routine. In addition
425-
* the application is responsible for @ref ucg_config_release "releasing" the
426-
* descriptor back to the UCG library.
427-
*
428-
* @param [in] env_prefix If non-NULL, the routine searches for the
429-
* environment variables that start with
430-
* @e \<env_prefix\>_UCX_ prefix.
431-
* Otherwise, the routine searches for the
432-
* environment variables that start with
433-
* @e UCX_ prefix.
434-
* @param [in] filename If non-NULL, read configuration from the file
435-
* defined by @e filename. If the file does not
436-
* exist, it will be ignored and no error reported
437-
* to the application.
438-
* @param [out] config_p Pointer to configuration descriptor as defined by
439-
* @ref ucg_config_t "ucg_config_t".
440-
*
441-
* @return Error code as defined by @ref ucs_status_t
442-
*/
443-
ucs_status_t ucg_config_read(const char *env_prefix, const char *filename,
444-
ucg_config_t **config_p);
445-
446-
/**
447-
* @ingroup UCG_CONFIG
448-
* @brief Release configuration descriptor
449-
*
450-
* The routine releases the configuration descriptor that was allocated through
451-
* @ref ucg_config_read "ucg_config_read()" routine.
452-
*
453-
* @param [out] config Configuration descriptor as defined by
454-
* @ref ucg_config_t "ucg_config_t".
455-
*/
456-
void ucg_config_release(ucg_config_t *config);
457-
458-
/**
459-
* @ingroup UCG_CONFIG
460-
* @brief Modify context configuration.
461-
*
462-
* The routine changes one configuration setting stored in @ref ucg_config_t
463-
* "configuration" descriptor.
464-
*
465-
* @param [in] config Configuration to modify.
466-
* @param [in] name Configuration variable name.
467-
* @param [in] value Value to set.
468-
*
469-
* @return Error code.
470-
*/
471-
ucs_status_t ucg_config_modify(ucg_config_t *config, const char *name,
472-
const char *value);
473-
474-
475-
/**
476-
* @ingroup UCG_CONFIG
477-
* @brief Print configuration information
478-
*
479-
* The routine prints the configuration information that is stored in
480-
* @ref ucg_config_t "configuration" descriptor.
481-
*
482-
* @todo Expose ucs_config_print_flags_t
483-
*
484-
* @param [in] config @ref ucg_config_t "Configuration descriptor"
485-
* to print.
486-
* @param [in] stream Output stream to print the configuration to.
487-
* @param [in] title Configuration title to print.
488-
* @param [in] print_flags Flags that control various printing options.
489-
*/
490-
void ucg_config_print(const ucg_config_t *config, FILE *stream,
491-
const char *title, ucs_config_print_flags_t print_flags);
354+
ucs_status_t ucg_init_version(unsigned api_major_version,
355+
unsigned api_minor_version,
356+
const ucp_params_t *params,
357+
const ucp_config_t *config,
358+
ucp_context_h *context_p);
492359

360+
ucs_status_t ucg_init(const ucp_params_t *params,
361+
const ucp_config_t *config,
362+
ucp_context_h *context_p);
493363

494-
/**
495-
* @ingroup UCG_CONTEXT
496-
* @brief Get UCG library version.
497-
*
498-
* This routine returns the UCG library version.
499-
*
500-
* @param [out] major_version Filled with library major version.
501-
* @param [out] minor_version Filled with library minor version.
502-
* @param [out] release_number Filled with library release number.
503-
*/
504-
void ucg_get_version(unsigned *major_version, unsigned *minor_version,
505-
unsigned *release_number);
506-
507-
/**
508-
* @ingroup UCG_CONTEXT
509-
* @brief Get UCG library version as a string.
510-
*
511-
* This routine returns the UCG library version as a string which consists of:
512-
* "major.minor.release".
513-
*/
514-
const char* ucg_get_version_string(void);
364+
ucs_status_t ucg_worker_create(ucp_context_h context,
365+
const ucp_worker_params_t *params,
366+
ucp_worker_h *worker_p);
515367

516368
END_C_DECLS
517369

0 commit comments

Comments
 (0)