1
1

Update the registry with some functionality and an early draft of the unit test.

I could use some help from one of you MCA gurus - if you run the test, you'll see that I cannot get the gpr components to be recognized. I'm not sure of the reason - I would appreciate any help you can provide to get the gpr components "registered".

This commit was SVN r2158.
Этот коммит содержится в:
Ralph Castain 2004-08-16 02:08:48 +00:00
родитель a1688d5b9f
Коммит 0d7c16f400
11 изменённых файлов: 248 добавлений и 35 удалений

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

@ -11,13 +11,6 @@ DIST_SUBDIRS = base $(MCA_gpr_ALL_SUBDIRS)
headers = gpr.h
noinst_LTLIBRARIES = libmca_gpr.la
libmca_gpr_la_SOURCES =
libmca_gpr_la_LIBADD = \
base/libmca_gpr_base.la \
$(MCA_gpr_STATIC_LTLIBS)
libmca_gpr_la_DEPENDENCIES = $(libmca_gpr_la_LIBADD)
# Conditionally install the header files
if WANT_INSTALL_HEADERS

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

@ -62,6 +62,7 @@ mca_gpr_base_component_t mca_gpr_base_selected_component;
*/
int mca_gpr_base_open(void)
{
int checksize;
/* Open up all available components */
@ -77,6 +78,8 @@ int mca_gpr_base_open(void)
}
mca_gpr_base_output = ompi_output_open(NULL);
checksize = ompi_list_get_size(&mca_gpr_base_components_available);
ompi_output(mca_gpr_base_output, "number of components: %d", checksize);
/* All done */

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

@ -34,6 +34,7 @@ int mca_gpr_base_select(bool *allow_multi_user_threads,
/* Iterate through all the available components */
ompi_output(mca_gpr_base_output, "in gpr_base_select");
for (item = ompi_list_get_first(&mca_gpr_base_components_available);
item != ompi_list_get_end(&mca_gpr_base_components_available);
item = ompi_list_get_next(item)) {
@ -42,7 +43,7 @@ int mca_gpr_base_select(bool *allow_multi_user_threads,
/* Call the component's init function and see if it wants to be
selected */
ompi_output(mca_gpr_base_output, "checking component");
module = component->gpr_init(&multi, &hidden, &priority);
/* If we got a non-NULL module back, then the component wants to
@ -51,7 +52,7 @@ int mca_gpr_base_select(bool *allow_multi_user_threads,
if (NULL != module) {
/* If this is the best one, save it */
ompi_output(mca_gpr_base_output, "priority: %d", priority);
if (priority > best_priority) {
/* If there was a previous best one, finalize */

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

@ -66,7 +66,6 @@ typedef uint16_t ompi_registry_notify_action_t;
typedef uint16_t ompi_registry_mode_t;
typedef ompi_buffer_t ompi_registry_object_t;
typedef uint32_t ompi_registry_object_size_t;
typedef char* ompi_registry_token_t;
/*
@ -94,7 +93,7 @@ OBJ_CLASS_DECLARATION(ompi_registry_value_t);
*/
struct ompi_registry_index_t {
ompi_list_item_t item; /**< Allows this item to be placed on a list */
ompi_registry_token_t *token; /**< Pointer to the token string */
char *token; /**< Pointer to the token string */
};
typedef struct ompi_registry_index_t ompi_registry_index_t;
@ -113,11 +112,13 @@ typedef ompi_registry_value_t* (*mca_gpr_base_module_get_fn_t)(ompi_registry_mod
typedef int (*mca_gpr_base_module_delete_fn_t)(ompi_registry_mode_t mode,
char *segment, char **tokens);
typedef ompi_registry_index_t* (*mca_gpr_base_module_index_fn_t)(char *segment);
typedef int (*mca_gpr_base_module_subscribe_fn_t)(ompi_registry_mode_t mode,
ompi_registry_notify_action_t action,
char *segment, char **tokens);
typedef int (*mca_gpr_base_module_unsubscribe_fn_t)(ompi_registry_mode_t mode,
char *segment, char **tokens);
typedef int (*mca_gpr_base_module_subscribe_fn_t)(ompi_process_name_t* subscriber,
ompi_registry_mode_t mode,
ompi_registry_notify_action_t action,
char *segment, char **tokens);
typedef int (*mca_gpr_base_module_unsubscribe_fn_t)(ompi_process_name_t* subscriber,
ompi_registry_mode_t mode,
char *segment, char **tokens);
/*

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

@ -2,11 +2,29 @@
# $HEADER$
#
# Use the top-level Makefile.options
include $(top_ompi_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libmca_gpr_proxy.la
libmca_gpr_proxy_la_SOURCES = \
gpr_proxy.h \
gpr_proxy.c \
gpr_proxy_component.c
# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
# (for static builds).
if OMPI_BUILD_gpr_proxy_DSO
component_noinst =
component_install = mca_gpr_proxy.la
else
component_noinst = libmca_gpr_proxy.la
component_install =
endif
mcacomponentdir = $(libdir)/openmpi
mcacomponent_LTLIBRARIES = $(component_install)
mca_gpr_proxy_la_SOURCES =
mca_gpr_proxy_la_LIBADD = src/libmca_gpr_proxy.la
mca_gpr_proxy_la_LDFLAGS = -module -avoid-version
noinst_LTLIBRARIES = $(component_noinst)
libmca_gpr_proxy_la_SOURCES =
libmca_gpr_proxy_la_LIBADD = src/libmca_gpr_proxy.la
libmca_gpr_proxy_la_LDFLAGS = -module -avoid-version

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

@ -51,16 +51,16 @@ ompi_registry_index_t* gpr_proxy_index(char *segment)
}
int gpr_proxy_subscribe(ompi_registry_mode_t mode,
ompi_registry_notify_action_t action,
char *segment, char **tokens)
int gpr_proxy_subscribe(ompi_process_name_t *caller, ompi_registry_mode_t mode,
ompi_registry_notify_action_t action,
char *segment, char **tokens)
{
return OMPI_SUCCESS;
}
int gpr_proxy_unsubscribe(ompi_registry_mode_t mode,
char *segment, char **tokens)
int gpr_proxy_unsubscribe(ompi_process_name_t *caller, ompi_registry_mode_t mode,
char *segment, char **tokens)
{
return OMPI_SUCCESS;
}

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

@ -65,14 +65,14 @@ ompi_registry_index_t* gpr_proxy_index(char *segment);
/*
* Implementation of subscribe()
*/
int gpr_proxy_subscribe(ompi_registry_mode_t mode,
int gpr_proxy_subscribe(ompi_process_name_t *caller, ompi_registry_mode_t mode,
ompi_registry_notify_action_t action,
char *segment, char **tokens);
/*
* Implementation of unsubscribe()
*/
int gpr_proxy_unsubscribe(ompi_registry_mode_t mode,
int gpr_proxy_unsubscribe(ompi_process_name_t *caller, ompi_registry_mode_t mode,
char *segment, char **tokens);
/*

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

@ -2,12 +2,29 @@
# $HEADER$
#
# Use the top-level Makefile.options
include $(top_ompi_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libmca_gpr_replica.la
libmca_gpr_replica_la_SOURCES = \
gpr_replica.h \
gpr_replica.c \
gpr_replica_internals.h \
gpr_replica_internals.c \
gpr_replica_component.c
# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
# (for static builds).
if OMPI_BUILD_gpr_replica_DSO
component_noinst =
component_install = mca_gpr_replica.la
else
component_noinst = libmca_gpr_replica.la
component_install =
endif
mcacomponentdir = $(libdir)/openmpi
mcacomponent_LTLIBRARIES = $(component_install)
mca_gpr_replica_la_SOURCES =
mca_gpr_replica_la_LIBADD = src/libmca_gpr_replica.la
mca_gpr_replica_la_LDFLAGS = -module -avoid-version
noinst_LTLIBRARIES = $(component_noinst)
libmca_gpr_replica_la_SOURCES =
libmca_gpr_replica_la_LIBADD = src/libmca_gpr_replica.la
libmca_gpr_replica_la_LDFLAGS = -module -avoid-version

28
test/mca/gpr/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,28 @@
# -*- makefile -*-
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
AM_CPPFLAGS = -I$(top_srcdir)/test/support -DOMPI_ENABLE_DEBUG_OVERRIDE=1
noinst_PROGRAMS = \
test_gpr_replica
test_gpr_replica_SOURCES = test_gpr_replica.c
test_gpr_replica_LDADD = \
$(top_builddir)/src/class/ompi_object.lo \
$(top_builddir)/src/util/malloc.lo \
$(top_builddir)/src/util/output.lo \
$(top_builddir)/src/util/argv.lo \
$(top_builddir)/src/util/strncpy.lo \
$(top_builddir)/src/mca/gpr/base/libmca_gpr_base.la \
$(top_builddir)/src/mca/gpr/replica/libmca_gpr_replica.la \
$(top_builddir)/src/mca/gpr/proxy/libmca_gpr_proxy.la \
$(top_builddir)/src/libmpi.la \
$(top_builddir)/src/threads/mutex.lo \
$(top_builddir)/src/threads/mutex_pthread.lo \
$(top_builddir)/src/threads/mutex_spinlock.lo \
$(top_builddir)/src/threads/mutex_spinwait.lo \
$(top_builddir)/test/support/libsupport.la
test_gpr_replica_DEPENDENCIES = $(test_gpr_replica_LDADD)

34
test/mca/gpr/run_tests Исполняемый файл
Просмотреть файл

@ -0,0 +1,34 @@
#! /bin/csh -f
# Name
# ====
# run script for mca ns tests
# Arguements
# ==========
#
# test_list = no args runs all tests
# or
# replica runs ompi ns replica tests
# Usage
#
# =====
# To invoke this script, enter either
# run_tests
# with no arguments to run all tests, or
# run_tests <test_name>
umask 007
if ("x$1" == "x") then
./test_ns_replica;
else if ("$1" == "replica") then
./test_ns_replica;
else
echo "correct use: "
echo " run_tests (to run all mca ns tests)"
echo "or run_tests < replica >"
exit -1
endif

118
test/mca/gpr/test_gpr_replica.c Обычный файл
Просмотреть файл

@ -0,0 +1,118 @@
/*
* unit test for General Purpose Registry replica.
--------------------------------------------------------------------------
Authors: Ralph H. Castain <rhc@lanl.gov>
--------------------------------------------------------------------------
*/
#include <stdio.h>
#include <string.h>
#include "ompi_config.h"
#include "support.h"
#include "include/constants.h"
#include "util/sys_info.h"
#include "util/proc_info.h"
#include "mca/mca.h"
#include "mca/base/base.h"
#include "mca/gpr/base/base.h"
#include "mca/gpr/replica/gpr_replica.h"
#include "mca/gpr/replica/gpr_replica_internals.h"
/* output files needed by the test */
static FILE *test_out=NULL;
static char *cmd_str="diff ./test_gpr_replica_out ./test_gpr_replica_out_std";
int main(int argc, char **argv)
{
mca_gpr_replica_key_t test_key, test_key2;
bool multi, hidden;
int i, j;
char *tmp;
int result; /* result from system call */
test_init("test_gpr_replica");
test_out = fopen( "test_gpr_replica_out", "w+" );
if( test_out == NULL ) {
test_failure("test_gpr_replica couldn't open test file failed");
test_finalize();
exit(1);
}
ompi_process_info.seed = true;
/* startup the MCA */
if (OMPI_SUCCESS == mca_base_open()) {
fprintf(test_out, "MCA started\n");
} else {
fprintf(test_out, "MCA could not start - please report error to bugs@open-mpi.org\n");
exit (1);
}
/* open the GPR */
if (OMPI_SUCCESS == mca_gpr_base_open()) {
fprintf(test_out, "GPR opened\n");
test_success();
} else {
fprintf(test_out, "GPR could not open\n");
test_failure("test_gpr_replica mca_gpr_base_open failed");
test_finalize();
exit(1);
}
/* startup the GPR replica */
if (OMPI_SUCCESS != mca_gpr_base_select(&multi, &hidden)) {
fprintf(test_out, "GPR replica could not start\n");
test_failure("test_gpr_replica mca_gpr_base_select failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "GPR replica started\n");
test_success();
}
/* define a key */
test_key = gpr_replica_define_key("universe", NULL);
if (0 == test_key) {
fprintf(test_out, "GPR replica: failed define key - %d\n", test_key);
test_failure("test_gpr_replica define_key failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "GPR replica: define_key succeeded - %d\n", test_key);
test_success();
}
/* get a key - check for correctness */
test_key2 = gpr_replica_get_key("universe", NULL);
if (test_key != test_key2) {
fprintf(test_out, "GPR replica: mismatched keys - %d %d\n", test_key, test_key2);
test_failure("test_gpr_replica get_key failed");
test_finalize();
exit(1);
} else {
fprintf(test_out, "GPR replica: get_key succeeded\n");
test_success();
}
fclose( test_out );
result = system( cmd_str );
if( result == 0 ) {
test_success();
}
else {
test_failure( "test_ns_replica ompi_name_server get_proc_name_string, etc failed");
}
test_finalize();
return(0);
}