1
1
* fixup lookup of supported ops by name:
        in ompi 1.5.x the op string representation were changed from MPI_XXX to MPI_OP_XXX (relative to OMPI 1.4.x)
		* keep compat between diff versions of FCA
		* better error handling (return error if symbol not found)
		* register to opal_progress and call fca_progress API

This commit was SVN r23597.
Этот коммит содержится в:
Mike Dubman 2010-08-12 08:15:55 +00:00
родитель 5715a5b421
Коммит ba5bc9b674
3 изменённых файлов: 120 добавлений и 62 удалений

Просмотреть файл

@ -48,9 +48,10 @@ BEGIN_C_DECLS
*/ */
struct mca_coll_fca_fca_ops_t { struct mca_coll_fca_fca_ops_t {
/* Initialization / cleanup */ /* FCA Context operations */
int (*init)(fca_init_spec_t *spec, fca_t **context); int (*init)(fca_init_spec_t *spec, fca_t **context);
void (*cleanup)(fca_t *context); void (*cleanup)(fca_t *context);
void (*progress)(fca_t *context);
/* Fabric communicator creation */ /* Fabric communicator creation */
int (*comm_new)(fca_t *context, fca_comm_new_spec_t *spec, fca_comm_desc_t *comm_desc); int (*comm_new)(fca_t *context, fca_comm_new_spec_t *spec, fca_comm_desc_t *comm_desc);
@ -71,6 +72,7 @@ struct mca_coll_fca_fca_ops_t {
int (*do_barrier)(fca_comm_t *comm); int (*do_barrier)(fca_comm_t *comm);
/* Helper functions */ /* Helper functions */
unsigned long (*get_version)(void);
int (*maddr_ib_pton)(const char *mlid_str, const char *mgid_str, fca_mcast_addr_t *dst); int (*maddr_ib_pton)(const char *mlid_str, const char *mgid_str, fca_mcast_addr_t *dst);
int (*maddr_inet_pton)(int af, const char *src, fca_mcast_addr_t *dst); int (*maddr_inet_pton)(int af, const char *src, fca_mcast_addr_t *dst);
fca_init_spec_t *(*parse_spec_file)(char* spec_ini_file); fca_init_spec_t *(*parse_spec_file)(char* spec_ini_file);

Просмотреть файл

@ -61,6 +61,139 @@ mca_coll_fca_component_t mca_coll_fca_component = {
} }
}; };
#define FCA_MINOR_BIT (16UL)
#define FCA_MAJOR_BIT (24UL)
#define FCA_API_CLEAR_MICRO(__x) ((__x>>FCA_MINOR_BIT)<<FCA_MINOR_BIT)
#define FCA_API_VER(__major,__minor) (__major<<FCA_MAJOR_BIT | __minor<<FCA_MINOR_BIT)
#define GET_FCA_SYM(__name) \
{ \
mca_coll_fca_component.fca_ops.__name = dlsym(mca_coll_fca_component.fca_lib_handle, "fca_" #__name);\
if (!mca_coll_fca_component.fca_ops.__name) { \
FCA_ERROR("Symbol %s not found", "fca_" #__name); \
return OMPI_ERROR; \
} \
}
/**
* Called from FCA blocking functions to progress MPI
*/
static void mca_coll_fca_progress_cb(void *arg)
{
opal_progress();
}
/**
* Called from MPI blocking functions to progress FCA
*/
static int mca_coll_fca_mpi_progress_cb(void)
{
if (!mca_coll_fca_component.fca_context)
return 0;
mca_coll_fca_component.fca_ops.progress(mca_coll_fca_component.fca_context);
return 0;
}
/**
* Initialize translation tables for FCA datatypes and operations
*/
static void mca_coll_fca_init_fca_translations(void)
{
int i, ret;
for (i = 0; i < FCA_DT_MAX_PREDEFINED; ++i) {
mca_coll_fca_component.fca_dtypes[i].mpi_dtype = MPI_DATATYPE_NULL;
mca_coll_fca_component.fca_dtypes[i].fca_dtype = -1;
mca_coll_fca_component.fca_dtypes[i].fca_dtype_extent = 0;
}
for (i = 0; i < FCA_MAX_OPS; ++i) {
mca_coll_fca_component.fca_reduce_ops[i].mpi_op = MPI_OP_NULL;
mca_coll_fca_component.fca_reduce_ops[i].fca_op = -1;
}
}
int mca_coll_fca_get_fca_lib(struct ompi_communicator_t *comm)
{
struct fca_init_spec *spec;
int ret;
unsigned long fca_ver;
if (mca_coll_fca_component.fca_lib_handle)
return OMPI_SUCCESS;
mca_coll_fca_component.fca_lib_handle = dlopen(mca_coll_fca_component.fca_lib_path, RTLD_LAZY);
if (!mca_coll_fca_component.fca_lib_handle) {
FCA_ERROR("Failed to load FCA from %s: %m", mca_coll_fca_component.fca_lib_path);
return OMPI_ERROR;
}
memset(&mca_coll_fca_component.fca_ops, 0, sizeof(mca_coll_fca_component.fca_ops));
FCA_VERBOSE(1, "FCA Loaded from: %s", mca_coll_fca_component.fca_lib_path);
GET_FCA_SYM(get_version);
fca_ver = FCA_API_CLEAR_MICRO(mca_coll_fca_component.fca_ops.get_version());
GET_FCA_SYM(init);
GET_FCA_SYM(cleanup);
GET_FCA_SYM(comm_new);
GET_FCA_SYM(comm_end);
GET_FCA_SYM(get_rank_info);
GET_FCA_SYM(free_rank_info);
GET_FCA_SYM(comm_init);
GET_FCA_SYM(comm_destroy);
GET_FCA_SYM(comm_get_caps);
GET_FCA_SYM(do_reduce);
GET_FCA_SYM(do_all_reduce);
GET_FCA_SYM(do_bcast);
GET_FCA_SYM(do_barrier);
GET_FCA_SYM(maddr_ib_pton);
GET_FCA_SYM(maddr_inet_pton);
GET_FCA_SYM(parse_spec_file);
GET_FCA_SYM(free_init_spec);
GET_FCA_SYM(translate_mpi_op);
GET_FCA_SYM(translate_mpi_dtype);
GET_FCA_SYM(get_dtype_size);
GET_FCA_SYM(strerror);
spec = mca_coll_fca_component.fca_ops.parse_spec_file(mca_coll_fca_component.fca_spec_file);
if (!spec) {
FCA_ERROR("Failed to parse FCA spec file `%s'", mca_coll_fca_component.fca_spec_file);
return OMPI_ERROR;
}
spec->job_id = ompi_proc_local()->proc_name.jobid;
spec->rank_id = ompi_comm_rank(MPI_COMM_WORLD);
spec->progress.func = mca_coll_fca_progress_cb;
spec->progress.arg = NULL;
ret = mca_coll_fca_component.fca_ops.init(spec, &mca_coll_fca_component.fca_context);
if (ret < 0) {
FCA_ERROR("Failed to initialize FCA: %s", mca_coll_fca_component.fca_ops.strerror(ret));
return OMPI_ERROR;
}
mca_coll_fca_component.fca_ops.free_init_spec(spec);
mca_coll_fca_init_fca_translations();
if (fca_ver > FCA_API_VER(1,2)) {
GET_FCA_SYM(progress);
opal_progress_register(mca_coll_fca_mpi_progress_cb);
}
return OMPI_SUCCESS;
}
static void mca_coll_fca_close_fca_lib(void)
{
if (NULL != mca_coll_fca_component.fca_ops.progress) {
opal_progress_unregister(mca_coll_fca_mpi_progress_cb);
}
mca_coll_fca_component.fca_ops.cleanup(mca_coll_fca_component.fca_context);
mca_coll_fca_component.fca_context = NULL;
dlclose(mca_coll_fca_component.fca_lib_handle);
mca_coll_fca_component.fca_lib_handle = NULL;
}
static int fca_open(void) static int fca_open(void)
{ {
@ -118,97 +251,6 @@ static int fca_close(void)
if (!mca_coll_fca_component.fca_lib_handle || !mca_coll_fca_component.fca_context) if (!mca_coll_fca_component.fca_lib_handle || !mca_coll_fca_component.fca_context)
return OMPI_SUCCESS; return OMPI_SUCCESS;
mca_coll_fca_component.fca_ops.cleanup(mca_coll_fca_component.fca_context); mca_coll_fca_close_fca_lib();
dlclose(mca_coll_fca_component.fca_lib_handle);
return OMPI_SUCCESS;
}
#define GET_FCA_SYM(__name) \
{ \
mca_coll_fca_component.fca_ops.__name = dlsym(mca_coll_fca_component.fca_lib_handle, "fca_" #__name);\
if (!mca_coll_fca_component.fca_ops.__name) { \
FCA_ERROR("Symbol %s not found", "fca_" #__name); \
} \
}
static void mca_coll_fca_progress_cb(void *arg)
{
opal_progress();
}
/**
* Initialize translation tables for FCA datatypes and operations
*/
static void mca_coll_fca_init_fca_translations(void)
{
int i, ret;
for (i = 0; i < FCA_DT_MAX_PREDEFINED; ++i) {
mca_coll_fca_component.fca_dtypes[i].mpi_dtype = MPI_DATATYPE_NULL;
mca_coll_fca_component.fca_dtypes[i].fca_dtype = -1;
mca_coll_fca_component.fca_dtypes[i].fca_dtype_extent = 0;
}
for (i = 0; i < FCA_MAX_OPS; ++i) {
mca_coll_fca_component.fca_reduce_ops[i].mpi_op = MPI_OP_NULL;
mca_coll_fca_component.fca_reduce_ops[i].fca_op = -1;
}
}
int mca_coll_fca_get_fca_lib(struct ompi_communicator_t *comm)
{
struct fca_init_spec *spec;
int ret;
if (mca_coll_fca_component.fca_lib_handle)
return OMPI_SUCCESS;
mca_coll_fca_component.fca_lib_handle = dlopen(mca_coll_fca_component.fca_lib_path, RTLD_LAZY);
if (!mca_coll_fca_component.fca_lib_handle) {
FCA_ERROR("Failed to load FCA from %s: %m", mca_coll_fca_component.fca_lib_path);
return OMPI_ERROR;
}
FCA_VERBOSE(1, "FCA Loaded from: %s", mca_coll_fca_component.fca_lib_path);
GET_FCA_SYM(init);
GET_FCA_SYM(cleanup);
GET_FCA_SYM(comm_new);
GET_FCA_SYM(comm_end);
GET_FCA_SYM(get_rank_info);
GET_FCA_SYM(free_rank_info);
GET_FCA_SYM(comm_init);
GET_FCA_SYM(comm_destroy);
GET_FCA_SYM(comm_get_caps);
GET_FCA_SYM(do_reduce);
GET_FCA_SYM(do_all_reduce);
GET_FCA_SYM(do_bcast);
GET_FCA_SYM(do_barrier);
GET_FCA_SYM(maddr_ib_pton);
GET_FCA_SYM(maddr_inet_pton);
GET_FCA_SYM(parse_spec_file);
GET_FCA_SYM(free_init_spec);
GET_FCA_SYM(translate_mpi_op);
GET_FCA_SYM(translate_mpi_dtype);
GET_FCA_SYM(get_dtype_size);
GET_FCA_SYM(strerror);
spec = mca_coll_fca_component.fca_ops.parse_spec_file(mca_coll_fca_component.fca_spec_file);
if (!spec) {
FCA_ERROR("Failed to parse FCA spec file `%s'", mca_coll_fca_component.fca_spec_file);
return OMPI_ERROR;
}
spec->job_id = ompi_proc_local()->proc_name.jobid;
spec->rank_id = ompi_comm_rank(MPI_COMM_WORLD);
spec->progress.func = mca_coll_fca_progress_cb;
spec->progress.arg = NULL;
ret = mca_coll_fca_component.fca_ops.init(spec, &mca_coll_fca_component.fca_context);
if (ret < 0) {
FCA_ERROR("Failed to initialize FCA: %s", mca_coll_fca_component.fca_ops.strerror(ret));
return OMPI_ERROR;
}
mca_coll_fca_component.fca_ops.free_init_spec(spec);
mca_coll_fca_init_fca_translations();
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -57,10 +57,23 @@ static mca_coll_fca_dtype_info_t* mca_coll_fca_get_dtype(ompi_datatype_t *dtype)
return dtype_info; return dtype_info;
} }
static void mca_coll_fca_get_op_name(ompi_op_t *op, char *name, int maxlen)
{
const char *ompi_op_prefix = "MPI_OP_";
const char *fca_op_prefix = "MPI_";
memset(name, 0, maxlen);
if (!strncmp(op->o_name, ompi_op_prefix, strlen(ompi_op_prefix)))
snprintf(name, maxlen, "%s%s", fca_op_prefix, op->o_name + strlen(ompi_op_prefix));
else
strncpy(name, op->o_name, maxlen);
}
static mca_coll_fca_op_info_t *mca_coll_fca_get_op(ompi_op_t *op) static mca_coll_fca_op_info_t *mca_coll_fca_get_op(ompi_op_t *op)
{ {
mca_coll_fca_op_info_t *op_info; mca_coll_fca_op_info_t *op_info;
int i, fca_op; int i, fca_op;
char opname[MPI_MAX_OBJECT_NAME + 1];
/* /*
* Find 'op' in the array by exhaustive search. We assume all valid ops are * Find 'op' in the array by exhaustive search. We assume all valid ops are
@ -72,7 +85,8 @@ static mca_coll_fca_op_info_t *mca_coll_fca_get_op(ompi_op_t *op)
if (op_info->mpi_op == op) { if (op_info->mpi_op == op) {
return op_info; return op_info;
} else if (op_info->mpi_op == MPI_OP_NULL) { } else if (op_info->mpi_op == MPI_OP_NULL) {
fca_op = mca_coll_fca_component.fca_ops.translate_mpi_op(op->o_name); mca_coll_fca_get_op_name(op, opname, MPI_MAX_OBJECT_NAME);
fca_op = mca_coll_fca_component.fca_ops.translate_mpi_op(opname);
if (fca_op < 0) if (fca_op < 0)
return NULL; return NULL;
op_info->mpi_op = op; op_info->mpi_op = op;