- initialize class constructors/destructors in OBJ_NEW
- initialize proc list This commit was SVN r771.
Этот коммит содержится в:
родитель
c3e9d72cb5
Коммит
98c557af5a
@ -55,9 +55,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
mkinstalldirs = $(mkdir_p)
|
||||
CONFIG_HEADER = config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
am__installdirs = $(DESTDIR)$(libdir) $(DESTDIR)$(man3dir) $(DESTDIR)$(includedir)
|
||||
libLTLIBRARIES_INSTALL = $(INSTALL)
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
am__DEPENDENCIES_1 = @LIBOBJS@
|
||||
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
|
||||
am_libevent_la_OBJECTS = event.lo
|
||||
@ -76,6 +74,7 @@ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
SOURCES = $(libevent_la_SOURCES)
|
||||
DIST_SOURCES = $(libevent_la_SOURCES)
|
||||
man3dir = $(mandir)/man3
|
||||
am__installdirs = $(DESTDIR)$(man3dir) $(DESTDIR)$(includedir)
|
||||
NROFF = nroff
|
||||
MANS = $(man_MANS)
|
||||
includeHEADERS_INSTALL = $(INSTALL_HEADER)
|
||||
@ -207,8 +206,8 @@ EXTRA_DIST = acconfig.h err.c event.h evsignal.h event.3 kqueue.c \
|
||||
WIN32-Prj/time_test/time_test.dsp
|
||||
|
||||
|
||||
# LAM: Changed to libevent.la
|
||||
lib_LTLIBRARIES = libevent.la
|
||||
# LAM: Changed to noinst and libevent.la
|
||||
noinst_LTLIBRARIES = libevent.la
|
||||
|
||||
# LAM: Get LIBOBJS and convert them to .lo (vs. .o)
|
||||
libobj = @LIBOBJS@
|
||||
@ -281,35 +280,17 @@ $(srcdir)/config.h.in: $(am__configure_deps) $(top_srcdir)/acconfig.h
|
||||
|
||||
distclean-hdr:
|
||||
-rm -f config.h stamp-h1
|
||||
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkdir_p) $(DESTDIR)$(libdir)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
f="`echo $$p | sed -e 's|^.*/||'`"; \
|
||||
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \
|
||||
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-libLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
p="`echo $$p | sed -e 's|^.*/||'`"; \
|
||||
echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
|
||||
done
|
||||
|
||||
clean-libLTLIBRARIES:
|
||||
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" = "$$p" && dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libevent.la: $(libevent_la_OBJECTS) $(libevent_la_DEPENDENCIES)
|
||||
$(LINK) -rpath $(libdir) $(libevent_la_LDFLAGS) $(libevent_la_OBJECTS) $(libevent_la_LIBADD) $(LIBS)
|
||||
$(LINK) $(libevent_la_LDFLAGS) $(libevent_la_OBJECTS) $(libevent_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
@ -575,7 +556,7 @@ check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES) $(MANS) $(HEADERS) config.h
|
||||
installdirs:
|
||||
$(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(man3dir) $(DESTDIR)$(includedir)
|
||||
$(mkdir_p) $(DESTDIR)$(man3dir) $(DESTDIR)$(includedir)
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
@ -603,7 +584,7 @@ maintainer-clean-generic:
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
@ -624,7 +605,7 @@ info-am:
|
||||
|
||||
install-data-am: install-includeHEADERS install-man
|
||||
|
||||
install-exec-am: install-libLTLIBRARIES
|
||||
install-exec-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
@ -651,26 +632,24 @@ ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-includeHEADERS uninstall-info-am \
|
||||
uninstall-libLTLIBRARIES uninstall-man
|
||||
uninstall-am: uninstall-includeHEADERS uninstall-info-am uninstall-man
|
||||
|
||||
uninstall-man: uninstall-man3
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
|
||||
clean-generic clean-libLTLIBRARIES clean-libtool ctags dist \
|
||||
clean-generic clean-libtool clean-noinstLTLIBRARIES ctags dist \
|
||||
dist-all dist-bzip2 dist-gzip dist-shar dist-tarZ dist-zip \
|
||||
distcheck distclean distclean-compile distclean-generic \
|
||||
distclean-hdr distclean-libtool distclean-tags distcleancheck \
|
||||
distdir distuninstallcheck dvi dvi-am html html-am info \
|
||||
info-am install install-am install-data install-data-am \
|
||||
install-exec install-exec-am install-includeHEADERS \
|
||||
install-info install-info-am install-libLTLIBRARIES \
|
||||
install-man install-man3 install-strip installcheck \
|
||||
installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-includeHEADERS \
|
||||
uninstall-info-am uninstall-libLTLIBRARIES uninstall-man \
|
||||
install-info install-info-am install-man install-man3 \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||
pdf pdf-am ps ps-am tags uninstall uninstall-am \
|
||||
uninstall-includeHEADERS uninstall-info-am uninstall-man \
|
||||
uninstall-man3
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
|
@ -348,6 +348,9 @@ static inline lam_object_t *lam_obj_new(size_t size,
|
||||
assert(size >= sizeof(lam_object_t));
|
||||
|
||||
object = (lam_object_t *) malloc(size);
|
||||
if (0 == cls->cls_initialized) {
|
||||
lam_class_initialize(cls);
|
||||
}
|
||||
if (NULL != object) {
|
||||
object->obj_class = cls;
|
||||
object->obj_reference_count = 1;
|
||||
|
@ -23,21 +23,26 @@ lam_class_t lam_pointer_array_t_class = {
|
||||
(lam_construct_t) lam_pointer_array_construct,
|
||||
(lam_destruct_t) lam_pointer_array_destruct
|
||||
};
|
||||
|
||||
/**
|
||||
* lam_pointer_array constructor
|
||||
*/
|
||||
void lam_pointer_array_construct(lam_pointer_array_t *new_pointer_array){
|
||||
void lam_pointer_array_construct(lam_pointer_array_t *array){
|
||||
|
||||
/* return */
|
||||
return;
|
||||
lam_mutex_init(&array->lock);
|
||||
array->lowest_free = 0;
|
||||
array->number_free = 0;
|
||||
array->size = 0;
|
||||
array->addr = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* lam_pointer_array destructor
|
||||
*/
|
||||
void lam_pointer_array_destruct(lam_pointer_array_t *pointer_array){
|
||||
void lam_pointer_array_destruct(lam_pointer_array_t *array){
|
||||
|
||||
/* return */
|
||||
lam_mutex_destroy(&array->lock);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,12 @@ static int lam_ifinit(void)
|
||||
lam_output(0, "lam_ifinit: ioctl(SIOCGIFFLAGS) failed with errno=%d", errno);
|
||||
continue;
|
||||
}
|
||||
if((ifr->ifr_flags & IFF_UP) == 0 || (ifr->ifr_flags & IFF_LOOPBACK) != 0)
|
||||
if ((ifr->ifr_flags & IFF_UP) == 0)
|
||||
continue;
|
||||
#if 0
|
||||
if ((ifr->ifr_flags & IFF_LOOPBACK) != 0)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
strcpy(intf.if_name, ifr->ifr_name);
|
||||
intf.if_flags = ifr->ifr_flags;
|
||||
|
@ -12,7 +12,7 @@
|
||||
int mca_base_modex_send(mca_base_module_t *source_module,
|
||||
void *buffer, size_t size, size_t count)
|
||||
{
|
||||
return LAM_ERR_NOT_IMPLEMENTED;
|
||||
return LAM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,6 +233,12 @@ static int mca_ptl_tcp_module_create_listen(void)
|
||||
mca_ptl_tcp_module.tcp_port = inaddr.sin_port;
|
||||
|
||||
/* register listen port */
|
||||
lam_event_set(
|
||||
&mca_ptl_tcp_module.tcp_recv_event,
|
||||
mca_ptl_tcp_module.tcp_listen,
|
||||
LAM_EV_READ|LAM_EV_PERSIST,
|
||||
mca_ptl_tcp_module_recv_handler,
|
||||
0);
|
||||
lam_event_add(&mca_ptl_tcp_module.tcp_recv_event, 0);
|
||||
return LAM_SUCCESS;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ void mca_ptl_tcp_send_frag_reinit(
|
||||
hdr->hdr_frag.hdr_src_ptr.pval = sendfrag;
|
||||
hdr->hdr_frag.hdr_dst_ptr.pval = 0;
|
||||
hdr->hdr_match.hdr_contextid = sendreq->super.req_communicator->c_contextid;
|
||||
hdr->hdr_match.hdr_src_rank = sendreq->super.req_communicator->c_rank;
|
||||
hdr->hdr_match.hdr_src_rank = sendreq->super.req_communicator->c_my_rank;
|
||||
hdr->hdr_match.hdr_dst_rank = sendreq->super.req_peer;
|
||||
hdr->hdr_match.hdr_user_tag = sendreq->super.req_tag;
|
||||
hdr->hdr_match.hdr_msg_length = sendreq->req_length;
|
||||
|
@ -5,13 +5,14 @@
|
||||
|
||||
include $(top_srcdir)/config/Makefile.options
|
||||
|
||||
SUBDIRS = communicator datatype info interface proc request runtime
|
||||
SUBDIRS = communicator datatype group info interface proc request runtime
|
||||
|
||||
noinst_LTLIBRARIES = libmpi_convenience.la
|
||||
|
||||
sources = \
|
||||
communicator/libmpi_communicator.la \
|
||||
datatype/libmpi_datatype.la \
|
||||
group/libmpi_group.la \
|
||||
info/libmpi_info.la \
|
||||
interface/libmpi_interface.la \
|
||||
proc/libmpi_proc.la \
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define LAM_COMMUNICATOR_H
|
||||
|
||||
#include "lam/stdint.h"
|
||||
#include "lam/lfc/lam_object.h"
|
||||
#include "lam/threads/mutex.h"
|
||||
#include "lam/util/output.h"
|
||||
#include "mpi.h"
|
||||
@ -13,18 +14,18 @@
|
||||
#include "mca/mpi/coll/coll.h"
|
||||
|
||||
|
||||
extern lam_class_t lam_communicator_t_class;
|
||||
|
||||
|
||||
struct lam_communicator_t {
|
||||
lam_object_t c_base;
|
||||
char c_name[MPI_MAX_OBJECT_NAME];
|
||||
uint32_t c_contextid;
|
||||
int c_refcount;
|
||||
int c_flags;
|
||||
size_t c_rank; /* local rank */
|
||||
int c_my_rank;
|
||||
|
||||
lam_group_t *c_local_group;
|
||||
lam_group_t *c_remote_group;
|
||||
|
||||
/* Queues */
|
||||
|
||||
/* Attributes */
|
||||
|
||||
/* Topology information */
|
||||
@ -60,7 +61,7 @@ static inline lam_communicator_t *lam_comm_lookup(uint32_t cid)
|
||||
return lam_mpi_comm_array[cid];
|
||||
}
|
||||
|
||||
static inline lam_proc_t* lam_comm_lookup_peer(lam_communicator_t* comm, size_t peer_id)
|
||||
static inline lam_proc_t* lam_comm_lookup_peer(lam_communicator_t* comm, int peer_id)
|
||||
{
|
||||
#if LAM_ENABLE_DEBUG
|
||||
if(peer_id >= comm->c_remote_group->grp_proc_count) {
|
||||
@ -75,8 +76,8 @@ static inline lam_proc_t* lam_comm_lookup_peer(lam_communicator_t* comm, size_t
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
int lam_comm_init(lam_communicator_t *comm);
|
||||
int lam_comm_link_function(void);
|
||||
int lam_comm_init(void);
|
||||
int lam_comm_link_function(void);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "lam_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mpi.h"
|
||||
#include "mpi/communicator/communicator.h"
|
||||
#include "mpi/group/group.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -21,26 +21,70 @@ lam_communicator_t lam_mpi_comm_world;
|
||||
lam_communicator_t lam_mpi_comm_self;
|
||||
|
||||
|
||||
static void lam_comm_construct(lam_communicator_t* comm)
|
||||
{
|
||||
comm->c_name[0] = '\0';
|
||||
comm->c_contextid = 0;
|
||||
comm->c_my_rank = 0;
|
||||
comm->c_local_group = NULL;
|
||||
comm->c_remote_group = NULL;
|
||||
comm->c_error_handler = NULL;
|
||||
comm->c_pml_comm = NULL;
|
||||
comm->c_coll_comm = NULL;
|
||||
}
|
||||
|
||||
static void lam_comm_destruct(lam_communicator_t* comm)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
lam_class_t lam_communicator_t_class = {
|
||||
"lam_communicator_t",
|
||||
OBJ_CLASS(lam_object_t),
|
||||
(lam_construct_t) lam_comm_construct,
|
||||
(lam_destruct_t) lam_comm_destruct
|
||||
};
|
||||
|
||||
/*
|
||||
* This function is here solely to allow non MPI progrlams be able to
|
||||
* have the globals listed above linked in (e.g., laminfo). According
|
||||
* to POSIX, we have to link in a function to guarantee that we can
|
||||
* get the global symbols in the relevant .o file.
|
||||
* For linking only.
|
||||
*/
|
||||
int lam_comm_link_function(void)
|
||||
{
|
||||
return LAM_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This is a shell function that needs to be filled in. It is here so
|
||||
* that this file will get linked into MPI executables (POSIX says
|
||||
* that linkers do not have to pull .o files from libraries without
|
||||
* function symbols -- global variable symbols alone are not
|
||||
* sufficient to pull in .o files).
|
||||
* Initialize comm world/self.
|
||||
*/
|
||||
int lam_comm_init(lam_communicator_t *comm)
|
||||
int lam_comm_init(void)
|
||||
{
|
||||
return LAM_SUCCESS;
|
||||
lam_group_t *group;
|
||||
size_t size;
|
||||
|
||||
/* Setup MPI_COMM_WORLD */
|
||||
OBJ_CONSTRUCT(&lam_mpi_comm_world, lam_communicator_t);
|
||||
group = OBJ_NEW(lam_group_t);
|
||||
group->grp_proc_pointers = lam_proc_world(&size);
|
||||
group->grp_my_rank = 0;
|
||||
group->grp_proc_count = size;
|
||||
OBJ_RETAIN(group); /* bump reference count for remote reference */
|
||||
|
||||
lam_mpi_comm_self.c_contextid = 0;
|
||||
lam_mpi_comm_self.c_my_rank = group->grp_my_rank;
|
||||
lam_mpi_comm_world.c_local_group = group;
|
||||
lam_mpi_comm_world.c_remote_group = group;
|
||||
|
||||
/* Setup MPI_COMM_SELF */
|
||||
OBJ_CONSTRUCT(&lam_mpi_comm_self, lam_communicator_t);
|
||||
group = OBJ_NEW(lam_group_t);
|
||||
group->grp_proc_pointers = lam_proc_self(&size);
|
||||
group->grp_my_rank = 0;
|
||||
group->grp_proc_count = size;
|
||||
|
||||
OBJ_RETAIN(group);
|
||||
lam_mpi_comm_self.c_contextid = 1;
|
||||
lam_mpi_comm_self.c_my_rank = group->grp_my_rank;
|
||||
lam_mpi_comm_self.c_local_group = group;
|
||||
lam_mpi_comm_self.c_remote_group = group;
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,21 @@
|
||||
#include <string.h>
|
||||
#include "lam/threads/mutex.h"
|
||||
#include "lam/util/output.h"
|
||||
#include "mpi/proc/proc.h"
|
||||
#include "mca/lam/pcm/pcm.h"
|
||||
|
||||
|
||||
static lam_list_t lam_proc_list;
|
||||
static lam_mutex_t lam_proc_lock;
|
||||
lam_proc_t* lam_proc_self = 0;
|
||||
lam_proc_t* lam_proc_local_proc = NULL;
|
||||
|
||||
static void lam_proc_construct(lam_proc_t* proc);
|
||||
static void lam_proc_destruct(lam_proc_t* proc);
|
||||
|
||||
|
||||
lam_class_t lam_proc_t_class = {
|
||||
"lam_proc_t",
|
||||
OBJ_CLASS(lam_list_t),
|
||||
OBJ_CLASS(lam_list_item_t),
|
||||
(lam_construct_t)lam_proc_construct,
|
||||
(lam_destruct_t)lam_proc_destruct
|
||||
};
|
||||
@ -39,3 +45,102 @@ void lam_proc_destruct(lam_proc_t* proc)
|
||||
THREAD_UNLOCK(&lam_proc_lock);
|
||||
}
|
||||
|
||||
|
||||
int lam_proc_init(void)
|
||||
{
|
||||
mca_pcm_proc_t *procs;
|
||||
mca_pcm_proc_t *local;
|
||||
size_t i, nprocs;
|
||||
int rc;
|
||||
|
||||
if(LAM_SUCCESS != (rc = mca_pcm.pcm_proc_startup())) {
|
||||
lam_output(0, "lam_proc_init: pcm_proc_startup failed with errno=%d", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if(NULL == (local = mca_pcm.pcm_proc_get_me())) {
|
||||
lam_output(0, "lam_proc_init: unable to determine local proc id");
|
||||
return LAM_ERROR;
|
||||
}
|
||||
|
||||
lam_proc_local_proc = OBJ_NEW(lam_proc_t);
|
||||
lam_proc_local_proc->proc_job = strdup(local->job_handle);
|
||||
lam_proc_local_proc->proc_vpid = local->vpid;
|
||||
if(LAM_SUCCESS != (rc = mca_pcm.pcm_proc_get_peers(&procs, &nprocs))) {
|
||||
lam_output(0, "lam_proc_init: pcm_proc_get_peers failed with errno=%d", rc);
|
||||
return rc;
|
||||
}
|
||||
lam_output(0, "lam_proc_init: pcm_proc_get_peers returned %d peers", nprocs);
|
||||
|
||||
for(i=0; i<nprocs; i++) {
|
||||
lam_proc_t *proc = OBJ_NEW(lam_proc_t);
|
||||
proc->proc_job = strdup(procs[i].job_handle);
|
||||
proc->proc_vpid = procs[i].vpid;
|
||||
}
|
||||
free(procs);
|
||||
return LAM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
lam_proc_t** lam_proc_world(size_t *size)
|
||||
{
|
||||
lam_proc_t **procs = malloc(lam_list_get_size(&lam_proc_list) * sizeof(lam_proc_t*));
|
||||
lam_proc_t *proc;
|
||||
lam_job_handle_t job;
|
||||
size_t count = 0;
|
||||
|
||||
if(NULL == procs)
|
||||
return NULL;
|
||||
|
||||
if(NULL == (job = mca_pcm.pcm_handle_get()))
|
||||
return NULL;
|
||||
|
||||
/* return only the procs that match this jobid */
|
||||
THREAD_LOCK(&lam_proc_lock);
|
||||
for(proc = (lam_proc_t*)lam_list_get_first(&lam_proc_list);
|
||||
proc != (lam_proc_t*)lam_list_get_end(&lam_proc_list);
|
||||
proc = (lam_proc_t*)lam_list_get_next(proc)) {
|
||||
if(strcmp(proc->proc_job,job) == 0) {
|
||||
OBJ_RETAIN(proc);
|
||||
procs[count++] = proc;
|
||||
}
|
||||
}
|
||||
THREAD_UNLOCK(&lam_proc_lock);
|
||||
*size = count;
|
||||
return procs;
|
||||
}
|
||||
|
||||
|
||||
lam_proc_t** lam_proc_all(size_t* size)
|
||||
{
|
||||
lam_proc_t **procs = malloc(lam_list_get_size(&lam_proc_list) * sizeof(lam_proc_t*));
|
||||
lam_proc_t *proc;
|
||||
size_t count = 0;
|
||||
|
||||
if(NULL == procs)
|
||||
return NULL;
|
||||
|
||||
THREAD_LOCK(&lam_proc_lock);
|
||||
for(proc = (lam_proc_t*)lam_list_get_first(&lam_proc_list);
|
||||
proc != (lam_proc_t*)lam_list_get_end(&lam_proc_list);
|
||||
proc = (lam_proc_t*)lam_list_get_next(proc)) {
|
||||
OBJ_RETAIN(proc);
|
||||
procs[count++] = proc;
|
||||
}
|
||||
THREAD_UNLOCK(&lam_proc_lock);
|
||||
*size = count;
|
||||
return procs;
|
||||
}
|
||||
|
||||
|
||||
lam_proc_t** lam_proc_self(size_t* size)
|
||||
{
|
||||
lam_proc_t **procs = malloc(sizeof(lam_proc_t*));
|
||||
if(NULL == procs)
|
||||
return NULL;
|
||||
OBJ_RETAIN(lam_proc_local_proc);
|
||||
*procs = lam_proc_local_proc;
|
||||
*size = 1;
|
||||
return procs;
|
||||
}
|
||||
|
||||
|
@ -30,13 +30,33 @@ struct lam_proc_t {
|
||||
typedef struct lam_proc_t lam_proc_t;
|
||||
|
||||
|
||||
void lam_proc_construct(lam_proc_t*);
|
||||
void lam_proc_destruct(lam_proc_t*);
|
||||
/**
|
||||
* Query the run-time environment and build list of available proc instances.
|
||||
*/
|
||||
int lam_proc_init(void);
|
||||
|
||||
/**
|
||||
* Returns the list of proc instances associated with this job.
|
||||
*/
|
||||
lam_proc_t** lam_proc_world(size_t* size);
|
||||
|
||||
/**
|
||||
* Returns the list of all known proc instances.
|
||||
*/
|
||||
lam_proc_t** lam_proc_all(size_t* size);
|
||||
|
||||
/**
|
||||
* Returns a list (of one) proc instances.
|
||||
*/
|
||||
lam_proc_t** lam_proc_self(size_t* size);
|
||||
|
||||
/**
|
||||
* Returns the proc instance corresponding to the local proc.
|
||||
*/
|
||||
static inline lam_proc_t* lam_proc_local(void)
|
||||
{
|
||||
extern lam_proc_t* lam_proc_self;
|
||||
return lam_proc_self;
|
||||
extern lam_proc_t* lam_proc_local_proc;
|
||||
return lam_proc_local_proc;
|
||||
}
|
||||
|
||||
#endif /* LAM_PROC */
|
||||
|
@ -33,80 +33,77 @@ int lam_mpi_thread_provided = MPI_THREAD_SINGLE;
|
||||
|
||||
int lam_mpi_init(int argc, char **argv, int requested, int *provided)
|
||||
{
|
||||
int ret;
|
||||
bool allow_multi_user_threads;
|
||||
bool have_hidden_threads;
|
||||
int ret;
|
||||
bool allow_multi_user_threads;
|
||||
bool have_hidden_threads;
|
||||
|
||||
/* Become a LAM process */
|
||||
/* Become a LAM process */
|
||||
|
||||
if (LAM_SUCCESS != (ret = lam_init(argc, argv))) {
|
||||
return ret;
|
||||
}
|
||||
if (LAM_SUCCESS != (ret = lam_init(argc, argv))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Open up the MCA */
|
||||
/* Open up the MCA */
|
||||
|
||||
if (LAM_SUCCESS != (ret = mca_base_open())) {
|
||||
return ret;
|
||||
}
|
||||
if (LAM_SUCCESS != (ret = mca_base_open())) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Join the run-time environment */
|
||||
/* Join the run-time environment */
|
||||
|
||||
if (LAM_SUCCESS != (ret = lam_rte_init(&allow_multi_user_threads,
|
||||
&have_hidden_threads))) {
|
||||
return ret;
|
||||
}
|
||||
if (LAM_SUCCESS != (ret = lam_rte_init(&allow_multi_user_threads, &have_hidden_threads))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Open up relevant MCA modules. Do not open io, topo, or one
|
||||
module types here -- they are loaded upon demand (i.e., upon
|
||||
relevant constructors). */
|
||||
/* Open up relevant MCA modules. Do not open io, topo, or one
|
||||
module types here -- they are loaded upon demand (i.e., upon
|
||||
relevant constructors). */
|
||||
|
||||
if (LAM_SUCCESS != (ret = mca_pml_base_open())) {
|
||||
/* JMS show_help */
|
||||
return ret;
|
||||
}
|
||||
if (LAM_SUCCESS != (ret = mca_ptl_base_open())) {
|
||||
/* JMS show_help */
|
||||
return ret;
|
||||
}
|
||||
if (LAM_SUCCESS != (ret = mca_coll_base_open())) {
|
||||
/* JMS show_help */
|
||||
return ret;
|
||||
}
|
||||
if (LAM_SUCCESS != (ret = mca_pml_base_open())) {
|
||||
/* JMS show_help */
|
||||
return ret;
|
||||
}
|
||||
if (LAM_SUCCESS != (ret = mca_ptl_base_open())) {
|
||||
/* JMS show_help */
|
||||
return ret;
|
||||
}
|
||||
if (LAM_SUCCESS != (ret = mca_coll_base_open())) {
|
||||
/* JMS show_help */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Select which pml, ptl, and coll modules to use, and determine the
|
||||
final thread level */
|
||||
/* Select which pml, ptl, and coll modules to use, and determine the
|
||||
final thread level */
|
||||
|
||||
if (LAM_SUCCESS !=
|
||||
(ret = mca_mpi_init_select_modules(requested, allow_multi_user_threads,
|
||||
have_hidden_threads, provided))) {
|
||||
/* JMS show_help */
|
||||
return ret;
|
||||
}
|
||||
if (LAM_SUCCESS !=
|
||||
(ret = mca_mpi_init_select_modules(requested, allow_multi_user_threads,
|
||||
have_hidden_threads, provided))) {
|
||||
/* JMS show_help */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Add MPI_COMM_WORLD lam_proc_t's to PML */
|
||||
/* initialize lam procs */
|
||||
if (LAM_SUCCESS != (ret = lam_proc_init())) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* All parent lam_proc_t's to PML */
|
||||
/* initialize communicators */
|
||||
if (LAM_SUCCESS != (ret = lam_comm_init())) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Save the resulting thread levels */
|
||||
/* do module exchange */
|
||||
|
||||
lam_mpi_thread_requested = requested;
|
||||
*provided = lam_mpi_thread_provided;
|
||||
lam_mpi_thread_multiple = (lam_mpi_thread_provided == MPI_THREAD_MULTIPLE);
|
||||
/* add all lam_proc_t's to PML */
|
||||
|
||||
#if 0
|
||||
/* Setup MPI_COMM_WORLD */
|
||||
/* save the resulting thread levels */
|
||||
|
||||
lam_comm_init(MPI_COMM_WORLD);
|
||||
lam_mpi_thread_requested = requested;
|
||||
*provided = lam_mpi_thread_provided;
|
||||
lam_mpi_thread_multiple = (lam_mpi_thread_provided == MPI_THREAD_MULTIPLE);
|
||||
|
||||
/* Setup MPI_COMM_SELF */
|
||||
/* All done */
|
||||
|
||||
lam_comm_init(MPI_COMM_SELF);
|
||||
#else
|
||||
lam_comm_link_function();
|
||||
#endif
|
||||
|
||||
/* All done */
|
||||
|
||||
lam_mpi_initialized = true;
|
||||
return MPI_SUCCESS;
|
||||
lam_mpi_initialized = true;
|
||||
return MPI_SUCCESS;
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user