1
1
This commit was SVN r27729.
Этот коммит содержится в:
Ralph Castain 2012-12-28 16:52:51 +00:00
родитель 07194c6564
Коммит 68329b516c
7 изменённых файлов: 16 добавлений и 608 удалений

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

@ -1,4 +1,4 @@
PROGS = no_op sigusr_trap spin orte_nodename orte_spawn orte_loop_spawn orte_loop_child orte_abort get_limits orte_ring spawn_child orte_tool orte_no_op binom oob_stress iof_stress iof_delay radix orte_barrier orte_mcast opal_interface mcast mcast_recv orte_spin segfault sysinfo orte_exit orte_db orte_sensor test-time event-threads psm_keygen regex orte_errors evpri-test opal-evpri-test evpri-test2 mapper reducer opal_hotel orte_dfs
PROGS = no_op sigusr_trap spin orte_nodename orte_spawn orte_loop_spawn orte_loop_child orte_abort get_limits orte_ring spawn_child orte_tool orte_no_op binom oob_stress iof_stress iof_delay radix orte_barrier opal_interface orte_spin segfault orte_exit orte_db orte_sensor test-time event-threads psm_keygen regex orte_errors evpri-test opal-evpri-test evpri-test2 mapper reducer opal_hotel orte_dfs
all: $(PROGS)

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

@ -1,159 +0,0 @@
/* -*- C -*-
*
* $HEADER$
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <signal.h>
#include <pthread.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main(int argc, char* argv[])
{
int rc, i;
char hostname[512];
pid_t pid;
int32_t i32=1;
int xmit, recv;
uint8_t ttl = 1;
uint16_t port=0;
struct sockaddr_in rx, inaddr;
struct ip_mreq req;
int addrlen;
uint32_t channel;
uint8_t bytes[256];
struct timespec ts, tsrem;
int flags;
fd_set fdset;
fd_set errset;
struct timeval tv;
char *nprocstr;
int nprocs;
gethostname(hostname, 512);
pid = getpid();
printf("orte_mcast: Node %s Pid %ld\n", hostname, (long)pid);
nprocstr = getenv("OMPI_COMM_WORLD_SIZE");
nprocs = strtol(nprocstr, NULL, 10);
/* create a recv socket */
recv = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(recv < 0) {
fprintf(stderr,"%d: rmcast:init: socket() failed\n", (int)pid);
exit(1);
}
flags = 1;
if (setsockopt (recv, SOL_SOCKET, SO_REUSEADDR, (const char *)&flags, sizeof(flags)) < 0) {
fprintf(stderr, "rmcast:basic: unable to set the SO_REUSEADDR option\n");
exit(1);
}
memset(&rx, 0, sizeof(rx));
rx.sin_family = AF_INET;
rx.sin_addr.s_addr = htonl(0xEFFF0001);
rx.sin_port = htons(5002);
/* bind the socket */
if (bind(recv, (struct sockaddr*)&rx, sizeof(rx)) < 0) {
fprintf(stderr, "%d: rmcast:init: bind()\n", (int)pid);
exit(1);
}
/* set membership to "any" */
memset(&req, 0, sizeof (req));
req.imr_multiaddr.s_addr = htonl(0xEFFF0001);
req.imr_interface.s_addr = htonl(INADDR_ANY);
if ((setsockopt(recv, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(void *)&req, sizeof (req))) < 0) {
fprintf(stderr, "%d: rmcast:init: sockopt()\n", (int)pid);
exit(1);
}
/* create a xmit socket */
xmit = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(xmit < 0) {
fprintf(stderr,"%d: rmcast:init: socket() failed\n", (int)pid);
exit(1);
}
/* set the multicast flags */
if ((setsockopt(xmit, IPPROTO_IP, IP_MULTICAST_TTL,
(void *)&ttl, sizeof(ttl))) < 0) {
fprintf(stderr,"%d: rmcast:init: socketopt() failed\n", (int)pid);
exit(1);
}
flags = 1;
if (setsockopt (xmit, SOL_SOCKET, SO_REUSEADDR, (const char *)&flags, sizeof(flags)) < 0) {
fprintf(stderr, "rmcast:basic: unable to set the SO_REUSEADDR option\n");
exit(1);
}
memset(&inaddr, 0, sizeof(inaddr));
inaddr.sin_family = AF_INET;
inaddr.sin_addr.s_addr = htonl(0xEFFF0001);
inaddr.sin_port = htons(5002);
addrlen = sizeof(struct sockaddr_in);
/* set membership to "any" */
memset(&req, 0, sizeof (req));
req.imr_multiaddr.s_addr = htonl(0xEFFF0001);
req.imr_interface.s_addr = htonl(INADDR_ANY);
if ((setsockopt(xmit, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(void *)&req, sizeof (req))) < 0) {
fprintf(stderr, "setsockopt() failed\n");
exit(1);
}
if ((rc = sendto(xmit, (char*)bytes, 256, 0, (struct sockaddr *)&inaddr, sizeof(struct sockaddr_in))) != 256) {
fprintf(stderr, "%d: send error %d\n", (int)pid, errno);
exit(1);
}
fprintf(stderr, "%d: MESSAGE SENT\n", (int)pid);
ts.tv_sec = 0;
ts.tv_nsec = 450*1000;
while (nanosleep(&ts, &tsrem) < 0) {
ts = tsrem;
}
tv.tv_sec = 1;
tv.tv_usec = 100*1000;
FD_ZERO(&fdset);
FD_ZERO(&errset);
FD_SET(recv, &fdset);
for (i=0; i < nprocs; i++) {
while ((rc = select(recv+1,
&fdset /* read-fds */, 0 /* write-fds */,
&errset /* error-fds */, NULL)) < 0) {
fprintf(stderr, "select\n");
}
if (0 == rc) {
fprintf(stderr, "select failed to find anything - errno %d\n", errno);
exit(0);
}
fprintf(stderr, "%d: MESSAGE ARRIVED...READING DATA\n", (int)pid);
addrlen = sizeof(rx);
rc = recvfrom(recv, bytes, 256, 0, (struct sockaddr *)&rx, &addrlen);
fprintf(stderr, "%d: RECVD %d bytes\n", (int)pid, rc);
}
exit(0);
}

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

@ -1,173 +0,0 @@
/* -*- C -*-
*
* $HEADER$
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <signal.h>
#include <pthread.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main(int argc, char* argv[])
{
int rc, i;
char hostname[512];
pid_t pid;
struct timeval tv;
int xmit, recv;
struct sockaddr_in rx, inaddr;
struct ip_mreq req;
fd_set fdset;
fd_set errset;
int flags;
int addrlen;
struct timespec ts, tsrem;
uint8_t ttl = 1;
uint8_t bytes[256];
char *nprocstr;
int nprocs;
gethostname(hostname, 512);
pid = getpid();
printf("orte_mcast_recv: Node %s Pid %ld\n",
hostname, (long)pid);
nprocstr = getenv("OMPI_COMM_WORLD_SIZE");
nprocs = strtol(nprocstr, NULL, 10);
/* create a xmit socket */
xmit = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(xmit < 0) {
fprintf(stderr,"%d: rmcast:init: socket() failed\n", (int)pid);
exit(1);
}
/* set the multicast flags */
if ((setsockopt(xmit, IPPROTO_IP, IP_MULTICAST_TTL,
(void *)&ttl, sizeof(ttl))) < 0) {
fprintf(stderr,"%d: rmcast:init: socketopt() failed\n", (int)pid);
exit(1);
}
flags = 1;
if (setsockopt (xmit, SOL_SOCKET, SO_REUSEADDR, (const char *)&flags, sizeof(flags)) < 0) {
fprintf(stderr, "rmcast:basic: unable to set the SO_REUSEADDR option\n");
exit(1);
}
memset(&inaddr, 0, sizeof(inaddr));
inaddr.sin_family = AF_INET;
inaddr.sin_addr.s_addr = htonl(0xEFFF0001);
inaddr.sin_port = htons(5002);
addrlen = sizeof(struct sockaddr_in);
/* set membership to "any" */
memset(&req, 0, sizeof (req));
req.imr_multiaddr.s_addr = htonl(0xEFFF0001);
req.imr_interface.s_addr = htonl(INADDR_ANY);
if ((setsockopt(xmit, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(void *)&req, sizeof (req))) < 0) {
fprintf(stderr, "setsockopt() failed\n");
exit(1);
}
/* create a recv socket */
recv = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(recv < 0) {
fprintf(stderr,"%d: rmcast:init: socket() failed\n", (int)pid);
exit(1);
}
flags = 1;
if (setsockopt (recv, SOL_SOCKET, SO_REUSEADDR, (const char *)&flags, sizeof(flags)) < 0) {
fprintf(stderr, "rmcast:basic: unable to set the SO_REUSEADDR option\n");
exit(1);
}
memset(&rx, 0, sizeof(rx));
rx.sin_family = AF_INET;
rx.sin_addr.s_addr = htonl(0xEFFF0001);
rx.sin_port = htons(5002);
/* bind the socket */
if (bind(recv, (struct sockaddr*)&rx, sizeof(rx)) < 0) {
fprintf(stderr, "%d: rmcast:init: bind()\n", (int)pid);
exit(1);
}
/* set membership to "any" */
memset(&req, 0, sizeof (req));
req.imr_multiaddr.s_addr = htonl(0xEFFF0001);
req.imr_interface.s_addr = htonl(INADDR_ANY);
if ((setsockopt(recv, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(void *)&req, sizeof (req))) < 0) {
fprintf(stderr, "%d: rmcast:init: sockopt()\n", (int)pid);
exit(1);
}
tv.tv_sec = 1;
tv.tv_usec = 100*1000;
FD_ZERO(&fdset);
FD_ZERO(&errset);
FD_SET(recv, &fdset);
while ((rc = select(recv+1,
&fdset /* read-fds */, 0 /* write-fds */,
&errset /* error-fds */, NULL)) < 0) {
fprintf(stderr, "select\n");
}
if (0 == rc) {
fprintf(stderr, "select failed to find anything - errno %d\n", errno);
exit(0);
}
fprintf(stderr, "%d: MESSAGE ARRIVED...READING DATA\n", (int)pid);
addrlen = sizeof(rx);
rc = recvfrom(recv, bytes, 256, 0, (struct sockaddr *)&rx, &addrlen);
fprintf(stderr, "%d: RECVD %d bytes...SENDING RESPONSE\n", (int)pid, rc);
/* send a reply */
if ((rc = sendto(xmit, (char*)bytes, 256, 0, (struct sockaddr *)&inaddr, sizeof(struct sockaddr_in))) != 256) {
fprintf(stderr, "%d: send error %d\n", (int)pid, errno);
exit(1);
}
fprintf(stderr, "%d: RESPONSE SENT\n", (int)pid);
ts.tv_sec = 0;
ts.tv_nsec = 450*1000;
while (nanosleep(&ts, &tsrem) < 0) {
ts = tsrem;
}
for (i=1; i < nprocs; i++) {
while ((rc = select(recv+1,
&fdset /* read-fds */, 0 /* write-fds */,
&errset /* error-fds */, NULL)) < 0) {
fprintf(stderr, "select\n");
}
if (0 == rc) {
fprintf(stderr, "select failed to find anything - errno %d\n", errno);
exit(0);
}
fprintf(stderr, "%d: MESSAGE ARRIVED...READING DATA\n", (int)pid);
addrlen = sizeof(rx);
rc = recvfrom(recv, bytes, 256, 0, (struct sockaddr *)&rx, &addrlen);
fprintf(stderr, "%d: RECVD %d bytes\n", (int)pid, rc);
}
exit(0);
}

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

@ -24,8 +24,8 @@ int main(int argc, char* argv[])
int rc;
char hostname[512];
pid_t pid;
orte_proc_t proc;
orte_proc_t *proc;
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
fprintf(stderr, "orte_db: couldn't init orte - error code %d\n", rc);
return rc;
@ -34,20 +34,20 @@ int main(int argc, char* argv[])
gethostname(hostname, 512);
pid = getpid();
OBJ_CONSTRUCT(&proc, orte_proc_t);
if (ORTE_SUCCESS != (rc = orte_db.store("test-insert", &proc, ORTE_PROC))) {
proc = OBJ_NEW(orte_proc_t);
if (ORTE_SUCCESS != (rc = orte_db.store(ORTE_PROC_MY_NAME, "test-insert", proc, ORTE_PROC))) {
ORTE_ERROR_LOG(rc);
}
if (ORTE_SUCCESS != (rc = orte_db.fetch("test-insert", &proc, ORTE_PROC))) {
if (ORTE_SUCCESS != (rc = orte_db.fetch(ORTE_PROC_MY_NAME, "test-insert", (void**)&proc, ORTE_PROC))) {
ORTE_ERROR_LOG(rc);
}
if (ORTE_SUCCESS != (rc = orte_db.store("test-insert2", &proc, ORTE_PROC))) {
if (ORTE_SUCCESS != (rc = orte_db.store(ORTE_PROC_MY_NAME, "test-insert2", proc, ORTE_PROC))) {
ORTE_ERROR_LOG(rc);
}
if (ORTE_SUCCESS != (rc = orte_db.fetch("test-insert2", &proc, ORTE_PROC))) {
if (ORTE_SUCCESS != (rc = orte_db.fetch(ORTE_PROC_MY_NAME, "test-insert2", (void**)&proc, ORTE_PROC))) {
ORTE_ERROR_LOG(rc);
}
OBJ_DESTRUCT(&proc);
OBJ_RELEASE(proc);
orte_finalize();
return 0;

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

@ -1,199 +0,0 @@
/* -*- C -*-
*
* $HEADER$
*
*/
#include <stdio.h>
#include <unistd.h>
#include "opal/dss/dss.h"
#include "opal/mca/event/event.h"
#include "opal/util/output.h"
#include "orte/util/proc_info.h"
#include "orte/util/name_fns.h"
#include "orte/runtime/orte_globals.h"
#include "orte/runtime/runtime.h"
#include "orte/runtime/orte_wait.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/rmcast/rmcast.h"
#include "orte/mca/grpcomm/grpcomm.h"
static void cbfunc(int status,
orte_rmcast_channel_t channel,
orte_rmcast_seq_t seq_num,
orte_rmcast_tag_t tag,
orte_process_name_t *sender,
opal_buffer_t *buf, void *cbdata);
static void cbfunc_buf_snt(int status,
orte_rmcast_channel_t channel,
orte_rmcast_seq_t seq_num,
orte_rmcast_tag_t tag,
orte_process_name_t *sender,
opal_buffer_t *buf, void *cbdata);
static void cbfunc_iovec(int status,
orte_rmcast_channel_t channel,
orte_rmcast_seq_t seq_num,
orte_rmcast_tag_t tag,
orte_process_name_t *sender,
struct iovec *msg, int count, void* cbdata);
static int datasize=1024;
static orte_rmcast_seq_t recvd_seq_num=0;
static orte_rmcast_seq_t sent_seq_num=0;
static void send_data(int fd, short flags, void *arg)
{
opal_buffer_t buf, *bfptr;
int32_t *i32;
struct iovec iovec_array[3];
int rc, i;
opal_event_t *tmp = (opal_event_t*)arg;
struct timeval now;
bfptr = OBJ_NEW(opal_buffer_t);
i32 = (int32_t*)malloc(datasize*sizeof(int32_t));
for (i=0; i < datasize; i++) {
i32[i] = -1;
}
opal_dss.pack(bfptr, i32, datasize, OPAL_INT32);
if (ORTE_SUCCESS != (rc = orte_rmcast.send_buffer_nb(ORTE_RMCAST_GROUP_OUTPUT_CHANNEL,
ORTE_RMCAST_TAG_OUTPUT, bfptr,
cbfunc_buf_snt, NULL))) {
ORTE_ERROR_LOG(rc);
return;
}
sent_seq_num++;
/* create an iovec array */
for (i=0; i < 3; i++) {
iovec_array[i].iov_base = (uint8_t*)malloc(datasize);
iovec_array[i].iov_len = datasize;
}
/* send it out */
if (ORTE_SUCCESS != (rc = orte_rmcast.send(ORTE_RMCAST_GROUP_OUTPUT_CHANNEL,
ORTE_RMCAST_TAG_OUTPUT,
iovec_array, 3))) {
ORTE_ERROR_LOG(rc);
return;
}
sent_seq_num++;
if (0 == (sent_seq_num % 100)) {
opal_output(0, "SENT SEQ_NUM %d", sent_seq_num);
}
/* reset the timer */
now.tv_sec = 0;
now.tv_usec = 1000;
opal_event_evtimer_add(tmp, &now);
}
int main(int argc, char* argv[])
{
int rc, i;
char hostname[512];
pid_t pid;
opal_buffer_t buf, *bfptr;
int32_t i32=1;
struct iovec iovec_array[3];
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
fprintf(stderr, "orte_mcast: couldn't init orte - error code %d\n", rc);
return rc;
}
gethostname(hostname, 512);
pid = getpid();
if (1 < argc) {
datasize = strtol(argv[1], NULL, 10);
}
printf("orte_mcast: Node %s Name %s Pid %ld datasize %d\n",
hostname, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), (long)pid, datasize);
if (0 == ORTE_PROC_MY_NAME->vpid) {
orte_grpcomm.barrier();
/* wake up every 5 seconds and send something */
ORTE_TIMER_EVENT(0, 1000, send_data);
} else {
/* setup to recv data on our channel */
if (ORTE_SUCCESS != (rc = orte_rmcast.recv_buffer_nb(ORTE_RMCAST_GROUP_OUTPUT_CHANNEL,
ORTE_RMCAST_TAG_OUTPUT,
ORTE_RMCAST_PERSISTENT,
cbfunc, NULL))) {
ORTE_ERROR_LOG(rc);
}
if (ORTE_SUCCESS != (rc = orte_rmcast.recv_nb(ORTE_RMCAST_GROUP_OUTPUT_CHANNEL,
ORTE_RMCAST_TAG_OUTPUT,
ORTE_RMCAST_PERSISTENT,
cbfunc_iovec, NULL))) {
ORTE_ERROR_LOG(rc);
}
orte_grpcomm.barrier(); /* ensure the public recv is ready */
}
opal_event_dispatch(orte_event_base);
blast:
orte_finalize();
return 0;
}
static void cbfunc(int status,
orte_rmcast_channel_t channel,
orte_rmcast_seq_t seq_num,
orte_rmcast_tag_t tag,
orte_process_name_t *sender,
opal_buffer_t *buffer, void *cbdata)
{
int32_t i32, rc;
/* retrieve the value sent */
rc = 1;
opal_dss.unpack(buffer, &i32, &rc, OPAL_INT32);
if (0 < recvd_seq_num) {
if ((seq_num - recvd_seq_num) != 1) {
opal_output(0, "%s MESSAGE LOST seq %d recvd_seq %d",
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), seq_num, recvd_seq_num);
}
}
recvd_seq_num = seq_num;
if (0 == (recvd_seq_num % 100)) {
opal_output(0, "RECVD SEQ_NUM %d", recvd_seq_num);
}
}
static void cbfunc_iovec(int status,
orte_rmcast_channel_t channel,
orte_rmcast_seq_t seq_num,
orte_rmcast_tag_t tag,
orte_process_name_t *sender,
struct iovec *msg, int count, void* cbdata)
{
if (0 < recvd_seq_num) {
if ((seq_num - recvd_seq_num) != 1) {
opal_output(0, "%s MESSAGE LOST seq %d recvd_seq %d",
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), seq_num, recvd_seq_num);
}
}
recvd_seq_num = seq_num;
if (0 == (recvd_seq_num % 100)) {
opal_output(0, "RECVD SEQ_NUM %d", recvd_seq_num);
}
}
static void cbfunc_buf_snt(int status,
orte_rmcast_channel_t channel,
orte_rmcast_seq_t seq_num,
orte_rmcast_tag_t tag,
orte_process_name_t *sender,
opal_buffer_t *buf, void *cbdata)
{
OBJ_RELEASE(buf);
}

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

@ -28,6 +28,7 @@ int main(int argc, char* argv[])
orte_process_name_t name;
struct iovec msg;
orte_vpid_t i;
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
fprintf(stderr, "couldn't init orte - error code %d\n", rc);
@ -47,7 +48,12 @@ int main(int argc, char* argv[])
getcwd(cwd, sizeof(cwd));
app->cwd = strdup(cwd);
app->user_specified_cwd = false;
/*===================================*/
char *host_list[] = {"vm2", "vm3", "vm4", NULL};
app->dash_host = host_list;
jdata->dyn_alloc_enabled = 1;
/*==================================*/
/* add the app to the job data */
opal_pointer_array_add(jdata->apps, app);
jdata->num_apps = 1;

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

@ -1,67 +0,0 @@
/* -*- C -*-
*
* $HEADER$
*
* The most basic of applications
*/
#include <stdio.h>
#include "orte/constants.h"
#include <sys/sysctl.h>
#include "opal/mca/sysinfo/sysinfo.h"
#include "opal/mca/sysinfo/base/base.h"
#include "orte/runtime/runtime.h"
int main(int argc, char* argv[])
{
char *keys[] = {
OPAL_SYSINFO_CPU_TYPE,
OPAL_SYSINFO_CPU_MODEL,
OPAL_SYSINFO_NUM_CPUS,
OPAL_SYSINFO_MEM_SIZE,
NULL
};
opal_list_t values;
opal_sysinfo_value_t *info;
opal_list_item_t *item;
char *model;
if (ORTE_SUCCESS != orte_init(&argc, &argv, ORTE_PROC_NON_MPI)) {
fprintf(stderr, "Failed orte_init\n");
exit(1);
}
OBJ_CONSTRUCT(&values, opal_list_t);
opal_sysinfo_base_open();
opal_sysinfo_base_select();
opal_sysinfo.query(keys, &values);
while (NULL != (item = opal_list_remove_first(&values))) {
info = (opal_sysinfo_value_t*)item;
fprintf(stderr, "Key: %s Value: ", info->key);
if (OPAL_INT64 == info->type) {
fprintf(stderr, "%ld\n", (long int)info->data.i64);
} else if (OPAL_STRING == info->type) {
fprintf(stderr, "%s\n", info->data.str);
}
OBJ_RELEASE(info);
}
OBJ_DESTRUCT(&values);
opal_sysinfo_base_close();
model = getenv("OMPI_MCA_cpu_model");
fprintf(stderr, "Envar cpu_model: %s\n", (NULL == model) ? "NULL" : model);
if (ORTE_SUCCESS != orte_finalize()) {
fprintf(stderr, "Failed orte_finalize\n");
exit(1);
}
return 0;
}