1
1
-in some cases failed to call complete function when the message
  was sent.
 -was freeing the wrong iovec in the base recv function
-added a first cut of a oob test

This commit was SVN r1849.
Этот коммит содержится в:
Tim Prins 2004-08-03 16:34:59 +00:00
родитель 772452105b
Коммит d209e538f1
7 изменённых файлов: 390 добавлений и 10 удалений

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

@ -906,6 +906,8 @@ AC_CONFIG_FILES([
test/include/Makefile
test/support/Makefile
test/class/Makefile
test/mca/Makefile
test/mca/oob/Makefile
test/threads/Makefile
test/util/Makefile
test/rte/Makefile

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

@ -37,7 +37,7 @@ static void mca_oob_base_recv_cb(int status, const ompi_process_name_t* peer,
/* unpack the data */
mca_oob_base_unpack(user_iovec[i].iov_base, msg[i].iov_base, num, MCA_OOB_BASE_INT32);
/* free the old buffer */
free(user_iovec[i].iov_base);
free(msg[i].iov_base);
}
}
/* free the iovecs we allocated */

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

@ -114,6 +114,8 @@ int mca_oob_tcp_peer_send(mca_oob_tcp_peer_t* peer, mca_oob_tcp_msg_t* msg)
if(!mca_oob_tcp_msg_send_handler(msg, peer)) {
peer->peer_send_msg = msg;
ompi_event_add(&peer->peer_send_event, 0);
} else {
mca_oob_tcp_msg_complete(msg, &peer->peer_name);
}
}
break;

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

@ -4,14 +4,7 @@
#
include $(top_srcdir)/config/Makefile.options
AM_CPPFLAGS = -I$(top_srcdir)/test/support -DOMPI_ENABLE_DEBUG_OVERRIDE=1
noinst_PROGRAMS = \
ns
ns_SOURCES = ns.c
ns_LDADD = \
$(top_builddir)/src/ns/name_server.lo \
$(top_builddir)/test/support/libsupport.la
ns_DEPENDENCIES = $(ompi_ns_LDADD)
SUBDIRS = oob
DIST_SUBDIRS = $(SUBDIRS) ns

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

@ -0,0 +1,24 @@
# -*- makefile -*-
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
AM_CPPFLAGS = -I$(top_srcdir)/test/support -DOMPI_ENABLE_DEBUG_OVERRIDE=1
noinst_PROGRAMS = \
oob_test \
oob_test_self
oob_test_SOURCES = oob_test.c
oob_test_LDADD = \
$(top_builddir)/test/support/libsupport.la \
$(top_builddir)/src/libmpi.la
oob_test_DEPENDENCIES = $(oob_test_LDADD)
oob_test_self_SOURCES = oob_test_self.c
oob_test_self_LDADD = \
$(top_builddir)/test/support/libsupport.la \
$(top_builddir)/src/libmpi.la
oob_test_self_DEPENDENCIES = $(oob_test_LDADD)

193
test/mca/oob/oob_test.c Обычный файл
Просмотреть файл

@ -0,0 +1,193 @@
/*
* Basic test for the oob
* to run:
* mpirun -np 2 -- oob_test
*/
#include <sys/uio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include "mpi.h"
#include "support.h"
#include "mca/oob/oob.h"
#define MSG_TYPE_1 1
#define MSG_TYPE_2 2
#define NUM_TESTS 4
bool testdone[NUM_TESTS];
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2, int n);
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2,
int n) {
int i;
for(i = 0; i < n; i++) {
if(msg1[i].iov_len != msg2[i].iov_len) {
return false;
}
if(0 != memcmp(msg1[i].iov_base, msg2[i].iov_base, msg1[i].iov_len)) {
return false;
}
}
return true;
}
void callback(int status, const ompi_process_name_t * peer,
const struct iovec * msg, int count, int tag, void * cbdata);
void callback(int status, const ompi_process_name_t * peer,
const struct iovec * msg, int count, int tag, void * cbdata)
{
if(0 != tag) {
test_failure("Bad tag.");
}
if((int) cbdata >= NUM_TESTS) {
test_failure("Bad value in callback function.");
} else if (testdone[(int) cbdata]) {
test_failure("Callback function called on an already completed test.");
} else {
testdone[(int) cbdata] = true;
test_success();
}
}
int main(int argc, char ** argv)
{
int rc;
ompi_process_name_t peer;
/* setup message */
uint32_t msg_type_1 = MSG_TYPE_1;
uint32_t msg_type_2 = MSG_TYPE_2;
char send1[] = "hello";
uint32_t send2[] = {3, 5, 5, 9, 20};
uint16_t send3[] = {32, 4, 23};
/* now we set up the send iovect */
struct iovec send_msg1[4] = {{(void *) &msg_type_1, sizeof(msg_type_1)},
{(void *) &send1, sizeof(send1)},
{(void *) &send2, sizeof(send2)},
{(void *) &send3, sizeof(send3)}};
struct iovec send_msg2[3] = {{(void *) &msg_type_2, sizeof(msg_type_2)},
{(void *) &send2, sizeof(send2)},
{(void *) &send3, sizeof(send3)}};
/* if we want the send/ recieve functions to do the packing for us,
* we have to provide an array that describes our data types
*/
mca_oob_base_type_t types[] = {MCA_OOB_BASE_INT32, MCA_OOB_BASE_BYTE,
MCA_OOB_BASE_INT32, MCA_OOB_BASE_INT16};
/* we'll pass the array an identical iovec */
uint32_t msg_type;
char recv1[5];
uint32_t recv2[5];
uint16_t recv3[3];
struct iovec recv_msg1[4] = {{(void *) &msg_type, sizeof(msg_type)},
{(void *) &recv1, sizeof(recv1)},
{(void *) &recv2, sizeof(recv2)},
{(void *) &recv3, sizeof(recv3)}};
struct iovec recv_msg2[3] = {{(void *) &msg_type, sizeof(msg_type)},
{(void *) &recv2, sizeof(recv2)},
{(void *) &recv3, sizeof(recv3)}};
MPI_Init(&argc, &argv);
/* setup peer address */
peer = mca_oob_name_self;
fprintf(stderr, "my vpid %d my jobid %d my cellid %d my pid %d\n",
peer.vpid, peer.jobid, peer.cellid, getpid());
if(peer.vpid == 1) {
test_init("oob send");
/* local vpid is 1 - peer is 0 */
peer.vpid = 0;
/* send without doing any packing */
if( 0 > (rc = mca_oob_send_nb(&peer, send_msg1, 4, 0, 0, &callback, (void *) 0))){
test_failure("mca_oob_send_nb.");
} else {
test_success();
}
/* send with packing */
if( 0 > (rc = mca_oob_send_hton_nb(&peer, send_msg1, types, 4, 0, 0, &callback,
(void *) 1))) {
test_failure("mca_oob_send_hton_nb.");
} else {
test_success();
}
/* blocking send of message type 2 */
if( 0 > (rc = mca_oob_send(&peer, send_msg2, 3, 0, 0))) {
test_failure("mca_oob_send.");
} else {
test_success();
}
test_finalize();
/* done */
} else {
test_init("oob recv");
/* local vpid is 0 - peer is 1 */
peer.vpid = 1;
/*first, we'll recieve the nonpacked send - assuming we know the message type */
if( 0 > (rc = mca_oob_recv_nb(&peer, recv_msg1, 4, 0, 0, &callback, (void *) 2))) {
test_failure("mca_oob_recv_nb.");
} else {
test_success();
}
/* now we'll recieve the packed send - assuming we know the message type */
if( 0 > mca_oob_recv_ntoh_nb(&peer, recv_msg1, types, 4, 0, 0, &callback, (void
*) 3)) {
test_failure("mca_oob_recv_ntoh_nb.");
} else {
test_success();
}
/* now we'll do a blocking recv - waiting for the 3rd message to arrive - and
* peek the first element of the iovec array to determine the message type.
*/
if( 0 > (rc = mca_oob_recv(&peer, recv_msg1, 1, 0, MCA_OOB_PEEK))) {
test_failure("mca_oob_recv w/peek.");
} else {
test_success();
}
/* check the type of message - before doing the actual receive */
switch(msg_type) {
case MSG_TYPE_1:
if( 0 > (rc = mca_oob_recv(&peer, recv_msg1, 4, 0, 0))) {
test_failure("mca_oob_recv_nb of peeked message.");
} else {
test_success();
}
if(!compare_iovec(recv_msg1, send_msg1, 4)) {
test_failure("compare is wrong");
}
break;
case MSG_TYPE_2:
if( 0 > (rc = mca_oob_recv(&peer, recv_msg2, 3, 0, 0))) {
test_failure("mca_oob_recv_nb of peeked message.");
} else {
test_success();
}
if(!compare_iovec(recv_msg2, send_msg2, 3)) {
test_failure("compare is wrong");
}
break;
default:
test_failure("Message peek did not return a valid type number.");
break;
}
test_finalize();
}
MPI_Finalize();
return 0;
}

166
test/mca/oob/oob_test_self.c Исполняемый файл
Просмотреть файл

@ -0,0 +1,166 @@
/**
* In this test we try using oob to send messages to the same process.
* to run: mpirun -np 1 -- oob_test_self
*/
#include <sys/uio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include "mpi.h"
#include "support.h"
#include "mca/oob/oob.h"
#define MSG_TYPE_1 1
#define MSG_TYPE_2 2
#define NUM_TESTS 5
bool testdone[NUM_TESTS];
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2, int n);
bool compare_iovec(const struct iovec * msg1, const struct iovec * msg2,
int n) {
int i;
for(i = 0; i < n; i++) {
if(msg1[i].iov_len != msg2[i].iov_len) {
return false;
}
if(0 != memcmp(msg1[i].iov_base, msg2[i].iov_base, msg1[i].iov_len)) {
return false;
}
}
return true;
}
void callback(int status, const ompi_process_name_t * peer,
const struct iovec * msg, int count, int tag, void * cbdata);
void callback(int status, const ompi_process_name_t * peer,
const struct iovec * msg, int count, int tag, void * cbdata)
{
if(0 != tag) {
test_failure("Bad tag.");
}
if((int) cbdata >= NUM_TESTS) {
test_failure("Bad value in callback function.");
} else if (testdone[(int) cbdata]) {
test_failure("Callback function called on an already completed test.");
} else {
testdone[(int) cbdata] = true;
test_success();
}
}
int main(int argc, char ** argv)
{
int rc;
ompi_process_name_t peer;
/* setup message */
uint32_t msg_type_1 = MSG_TYPE_1;
uint32_t msg_type_2 = MSG_TYPE_2;
char send1[] = "hello";
uint32_t send2[] = {3, 5, 5, 9, 20};
uint16_t send3[] = {32, 4, 23};
/* now we set up the send iovect */
struct iovec send_msg1[4] = {{(void *) &msg_type_1, sizeof(msg_type_1)},
{(void *) &send1, sizeof(send1)},
{(void *) &send2, sizeof(send2)},
{(void *) &send3, sizeof(send3)}};
struct iovec send_msg2[3] = {{(void *) &msg_type_2, sizeof(msg_type_2)},
{(void *) &send2, sizeof(send2)},
{(void *) &send3, sizeof(send3)}};
/* if we want the send/ recieve functions to do the packing for us,
* we have to provide an array that describes our data types
*/
mca_oob_base_type_t types[] = {MCA_OOB_BASE_INT32, MCA_OOB_BASE_BYTE,
MCA_OOB_BASE_INT32, MCA_OOB_BASE_INT16};
/* we'll pass the array an identical iovec */
uint32_t msg_type;
char recv1[5];
uint32_t recv2[5];
uint16_t recv3[3];
struct iovec recv_msg1[4] = {{(void *) &msg_type, sizeof(msg_type)},
{(void *) &recv1, sizeof(recv1)},
{(void *) &recv2, sizeof(recv2)},
{(void *) &recv3, sizeof(recv3)}};
struct iovec recv_msg2[3] = {{(void *) &msg_type, sizeof(msg_type)},
{(void *) &recv2, sizeof(recv2)},
{(void *) &recv3, sizeof(recv3)}};
MPI_Init(&argc, &argv);
/* setup peer address */
peer = mca_oob_name_self;
fprintf(stderr, "my vpid %d my jobid %d my cellid %d my pid %d\n",
peer.vpid, peer.jobid, peer.cellid, getpid());
test_init("oob self");
/* do a non blocking send without packing followed by a
* non blocking recieve */
if( 0 > (rc = mca_oob_send_nb(&peer, send_msg1, 4, 0, 0, &callback, (void *) 0))){
test_failure("mca_oob_send_nb.");
} else {
test_success();
}
if( 0 > (rc = mca_oob_recv_nb(&peer, recv_msg1, 4, 0, 0, &callback, (void *) 2))) {
test_failure("mca_oob_recv_nb.");
} else {
test_success();
}
/* Nonblocking send followed by a blocking recieve with packing */
if( 0 > (rc = mca_oob_send_hton_nb(&peer, send_msg1, types, 4, 0, 0, &callback,
(void *) 1))) {
test_failure("mca_oob_send_hton_nb.");
} else {
test_success();
}
if( 0 > mca_oob_recv_ntoh_nb(&peer, recv_msg1, types, 4, 0, 0, &callback, (void
*) 3)) {
test_failure("mca_oob_recv_ntoh_nb.");
} else {
test_success();
}
/* non blocking send of message type 2 */
if( 0 > (rc = mca_oob_send_nb(&peer, send_msg2, 3, 0, 0, &callback,
(void *) 4))) {
test_failure("mca_oob_send.");
} else {
test_success();
}
if( 0 > (rc = mca_oob_recv(&peer, recv_msg1, 1, 0, MCA_OOB_PEEK))) {
test_failure("mca_oob_recv w/peek.");
} else {
test_success();
}
/* check the type of message - before doing the actual receive */
switch(msg_type) {
case MSG_TYPE_1:
if( 0 > (rc = mca_oob_recv(&peer, recv_msg1, 4, 0, 0))) {
test_failure("mca_oob_recv_nb of peeked message.");
} else {
test_success();
}
break;
case MSG_TYPE_2:
if( 0 > (rc = mca_oob_recv(&peer, recv_msg2, 3, 0, 0))) {
test_failure("mca_oob_recv_nb of peeked message.");
} else {
test_success();
}
break;
default:
test_failure("Message peek did not return a valid type number.");
break;
}
test_finalize();
MPI_Finalize();
return 0;
}