1
1
openmpi/opal/mca/btl/usnic/btl_usnic_test.c
Ralph Castain 552c9ca5a0 George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT:    Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL

All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies.  This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP.  Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose.  UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs.  A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.

This commit was SVN r32317.
2014-07-26 00:47:28 +00:00

128 строки
3.1 KiB
C

/*
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include <stdio.h>
#include "opal/class/opal_list.h"
#include "btl_usnic.h"
#include "btl_usnic_test.h"
int opal_btl_usnic_num_tests_run = 0;
int opal_btl_usnic_num_tests_passed = 0;
int opal_btl_usnic_num_tests_failed = 0;
int opal_btl_usnic_num_tests_skipped = 0;
struct test_info {
opal_list_item_t li;
char *name;
opal_btl_usnic_test_fn_t test_fn;
void *ctx;
};
#if OPAL_BTL_USNIC_UNIT_TESTS
static bool initialized = false;
static opal_list_t all_tests;
void opal_btl_usnic_cleanup_tests(void)
{
opal_list_item_t *li;
struct test_info *info;
if (initialized) {
while (NULL != (li = opal_list_remove_first(&all_tests))) {
info = container_of(li, struct test_info, li);
free(info);
}
OBJ_DESTRUCT(&all_tests);
}
initialized = false;
}
static void init_test_infra(void)
{
if (!initialized) {
OBJ_CONSTRUCT(&all_tests, opal_list_t);
initialized = true;
}
}
void opal_btl_usnic_register_test(const char *name,
opal_btl_usnic_test_fn_t test_fn,
void *ctx)
{
struct test_info *info = malloc(sizeof(*info));
assert(info != NULL);
OBJ_CONSTRUCT(&info->li, opal_list_item_t);
init_test_infra();
info->name = strdup(name);
info->test_fn = test_fn;
info->ctx = ctx;
opal_list_append(&all_tests, &info->li);
}
void opal_btl_usnic_run_tests(void)
{
struct test_info *info;
enum test_result result;
if (!OPAL_BTL_USNIC_UNIT_TESTS) {
test_out("unit tests disabled in this build, doing nothing!\n");
return;
}
test_out("STARTING TESTS\n");
OPAL_LIST_FOREACH(info, &all_tests, struct test_info) {
test_out("running test '%s'... ", info->name);
result = info->test_fn(info->ctx);
++opal_btl_usnic_num_tests_run;
switch (result) {
case TEST_PASSED:
++opal_btl_usnic_num_tests_passed;
test_out("PASSED\n");
break;
case TEST_FAILED:
++opal_btl_usnic_num_tests_failed;
test_out("FAILED\n");
break;
case TEST_SKIPPED:
++opal_btl_usnic_num_tests_skipped;
test_out("SKIPPED\n");
break;
}
}
test_out("FINISHED TESTS (%d passed, %d failed, %d skipped)\n",
opal_btl_usnic_num_tests_passed,
opal_btl_usnic_num_tests_failed,
opal_btl_usnic_num_tests_skipped);
}
#else /* !OPAL_BTL_USNIC_UNIT_TESTS */
void opal_btl_usnic_register_test(const char *name,
opal_btl_usnic_test_fn_t test_fn,
void *ctx)
{
abort(); /* never should be called */
}
void opal_btl_usnic_run_tests(void)
{
test_out("unit tests disabled in this build, doing nothing!\n");
return;
}
#endif /* !OPAL_BTL_USNIC_UNIT_TESTS */