Update the tests, add a couple
This commit was SVN r26379.
Этот коммит содержится в:
родитель
c5da4f24d7
Коммит
40c2fc5f55
@ -1,4 +1,4 @@
|
||||
PROGS = mpi_no_op mpi_barrier hello hello_nodename abort multi_abort simple_spawn concurrent_spawn spawn_multiple mpi_spin delayed_abort loop_spawn loop_child bad_exit pubsub hello_barrier segv accept connect hello_output hello_show_help crisscross read_write ziatest slave_spawn slave cell_spawn reduce-hang ziaprobe ziatest bcast_loop parallel_w8 parallel_w64 parallel_r8 parallel_r64 sio sendrecv_blaster hello++ hellof90 early_abort debugger singleton_client_server intercomm_create spawn_tree init-exit77
|
||||
PROGS = mpi_no_op mpi_barrier hello hello_nodename abort multi_abort simple_spawn concurrent_spawn spawn_multiple mpi_spin delayed_abort loop_spawn loop_child bad_exit pubsub hello_barrier segv accept connect hello_output hello_show_help crisscross read_write ziatest slave_spawn slave cell_spawn reduce-hang ziaprobe ziatest bcast_loop parallel_w8 parallel_w64 parallel_r8 parallel_r64 sio sendrecv_blaster early_abort debugger singleton_client_server intercomm_create spawn_tree init-exit77
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
|
@ -100,7 +100,7 @@ int main(int argc, char *argv[])
|
||||
if (mpierr != MPI_SUCCESS)
|
||||
{
|
||||
fprintf(stderr,"MPI Error %d (MPI_Get_processor_name) [%d]\n", mpierr, rank);
|
||||
sprintf(process_name, rr_empty);
|
||||
sprintf(process_name, "%s", rr_empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,24 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
|
||||
// University Research and Technology
|
||||
// Corporation. All rights reserved.
|
||||
// Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
|
||||
//
|
||||
// Sample MPI "hello world" application in C++
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "mpi.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rank, size;
|
||||
|
||||
MPI::Init(argc, argv);
|
||||
rank = MPI::COMM_WORLD.Get_rank();
|
||||
size = MPI::COMM_WORLD.Get_size();
|
||||
std::cout << "Hello, world! I am " << rank << " of " << size << std::endl;
|
||||
MPI::Finalize();
|
||||
|
||||
return 0;
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
* The most basic of MPI applications
|
||||
*/
|
||||
#include "opal_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "mpi.h"
|
||||
|
@ -5,6 +5,8 @@
|
||||
* The most basic of MPI applications
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "mpi.h"
|
||||
|
@ -1,21 +0,0 @@
|
||||
!
|
||||
! Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
|
||||
! University Research and Technology
|
||||
! Corporation. All rights reserved.
|
||||
! Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
! All rights reserved.
|
||||
! Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
|
||||
!
|
||||
! Sample MPI "hello world" application in Fortran 90
|
||||
!
|
||||
program main
|
||||
use mpi
|
||||
implicit none
|
||||
integer :: ierr, rank, size
|
||||
|
||||
call MPI_INIT(ierr)
|
||||
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
|
||||
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
|
||||
print *, "Hello, world, I am ", rank, " of ", size
|
||||
call MPI_FINALIZE(ierr)
|
||||
end
|
@ -69,7 +69,7 @@ main(int argc, char* argv[])
|
||||
printf(" number of PE's in x direction: %4d\n",npx);
|
||||
printf(" number of PE's in y direction: %4d\n",npy);
|
||||
printf(" number of PE's in z direction: %4d\n",npz);
|
||||
printf(" global grid size: %dx%dx%d 4 byte integers (total %lld)\n",X,Y,Z,(unsigned long)X*Y*Z);
|
||||
printf(" global grid size: %dx%dx%d 4 byte integers (total %lu)\n",X,Y,Z,(unsigned long)X*Y*Z);
|
||||
printf(" local grid size: %dx%dx%d 4 byte integers (total %d)\n",nx,ny,nz,ng);
|
||||
}
|
||||
else
|
||||
@ -85,7 +85,7 @@ main(int argc, char* argv[])
|
||||
}
|
||||
if ( MPI_Get_processor_name(process_name, &count) != MPI_SUCCESS)
|
||||
{
|
||||
sprintf(process_name, rr_empty);
|
||||
sprintf(process_name, "%s", rr_empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ main(int argc, char* argv[])
|
||||
printf(" number of PE's in x direction: %4d\n",npx);
|
||||
printf(" number of PE's in y direction: %4d\n",npy);
|
||||
printf(" number of PE's in z direction: %4d\n",npz);
|
||||
printf(" global grid size: %dx%dx%d 4 byte integers (total %lld)\n",X,Y,Z,(unsigned long)X*Y*Z);
|
||||
printf(" global grid size: %dx%dx%d 4 byte integers (total %lu)\n",X,Y,Z,(unsigned long)X*Y*Z);
|
||||
printf(" local grid size: %dx%dx%d 4 byte integers (total %d)\n",nx,ny,nz,ng);
|
||||
}
|
||||
else
|
||||
@ -84,7 +84,7 @@ main(int argc, char* argv[])
|
||||
}
|
||||
if ( MPI_Get_processor_name(process_name, &count) != MPI_SUCCESS)
|
||||
{
|
||||
sprintf(process_name, rr_empty);
|
||||
sprintf(process_name, "%s", rr_empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -41,8 +41,8 @@ int main(int argc, char *argv[])
|
||||
MPI_Abort(MPI_COMM_WORLD, 1);
|
||||
}
|
||||
while (NULL != fgets(line, sizeof(line), stdin)) {
|
||||
fprintf(stderr, line);
|
||||
fprintf(file, line);
|
||||
fprintf(stderr, "%s", line);
|
||||
fprintf(file, "%s", line);
|
||||
bytes += strlen(line) + 1;
|
||||
}
|
||||
fclose(file);
|
||||
|
@ -28,7 +28,7 @@ pi = 3.14159 * 18.0 / 35.3;
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
}
|
||||
if (0 == (++count % 10000)) {
|
||||
fprintf(stderr, "%ld still going at %d\n", self, count);
|
||||
fprintf(stderr, "%d still going at %ld\n", self, count);
|
||||
}
|
||||
}
|
||||
MPI_Finalize();
|
||||
|
@ -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
|
||||
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
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/mca/event/event.h"
|
||||
|
||||
static orte_event_base_t *my_base=NULL;
|
||||
static opal_event_base_t *my_base=NULL;
|
||||
static opal_thread_t progress_thread;
|
||||
static bool progress_thread_stop=false;
|
||||
static int progress_thread_pipe[2];
|
||||
@ -42,7 +42,7 @@ int main(int argc, char **argv)
|
||||
opal_event_use_threads();
|
||||
|
||||
/* create a new base */
|
||||
my_base = orte_event_base_create();
|
||||
my_base = opal_event_base_create();
|
||||
|
||||
/* launch a progress thread on that base*/
|
||||
pipe(progress_thread_pipe);
|
||||
@ -52,7 +52,6 @@ int main(int argc, char **argv)
|
||||
progress_thread.t_run = progress_engine;
|
||||
if (OPAL_SUCCESS != opal_thread_start(&progress_thread)) {
|
||||
fprintf(stderr, "Unable to start progress thread\n");
|
||||
orte_event_base_finalize(my_base);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
74
orte/test/system/mapper.c
Обычный файл
74
orte/test/system/mapper.c
Обычный файл
@ -0,0 +1,74 @@
|
||||
/* -*- C -*-
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "orte/constants.h"
|
||||
|
||||
#include "opal/util/argv.h"
|
||||
|
||||
#include "orte/runtime/runtime.h"
|
||||
#include "orte/util/proc_info.h"
|
||||
#include "orte/util/name_fns.h"
|
||||
#include "orte/runtime/orte_globals.h"
|
||||
|
||||
#define LINE_LENGTH 10000
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char text[LINE_LENGTH];
|
||||
char **invals=NULL;
|
||||
int i, j;
|
||||
|
||||
if (1 < argc) {
|
||||
if (ORTE_SUCCESS != orte_init(&argc, &argv, ORTE_PROC_NON_MPI)) {
|
||||
fprintf(stderr, "Failed orte_init\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
memset(text, 0, sizeof(text));
|
||||
while (fgets(text, sizeof(text), stdin)) {
|
||||
/* remove trailing newline */
|
||||
if ('\n' == text[strlen(text)-1]) {
|
||||
text[strlen(text)-1] = '\0';
|
||||
}
|
||||
/* break the line on white space */
|
||||
for (i=0, j=0; i < LINE_LENGTH && '\0' != text[i]; i++) {
|
||||
if (isspace(text[i])) {
|
||||
if (j < i) {
|
||||
text[i] = '\0';
|
||||
opal_argv_append_nosize(&invals, &text[j]);
|
||||
}
|
||||
j = i+1;
|
||||
}
|
||||
}
|
||||
if (i < LINE_LENGTH && j < i+1) {
|
||||
opal_argv_append_nosize(&invals, &text[j]);
|
||||
}
|
||||
if (NULL == invals) {
|
||||
fprintf(stderr, "stdin complete (text strlen: %lu)\n", strlen(text));
|
||||
break;
|
||||
}
|
||||
for (i=0; NULL != invals[i]; i++) {
|
||||
fprintf(stdout, "%s\t1\n", invals[i]);
|
||||
}
|
||||
if (NULL != invals) {
|
||||
opal_argv_free(invals);
|
||||
invals = NULL;
|
||||
}
|
||||
memset(text, 0, sizeof(text));
|
||||
}
|
||||
|
||||
if (1 < argc) {
|
||||
fprintf(stderr, "%s: FINALIZING\n", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
|
||||
fflush(stderr);
|
||||
|
||||
if (ORTE_SUCCESS != orte_finalize()) {
|
||||
fprintf(stderr, "Failed orte_finalize\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
18
orte/test/system/mapr.py
Исполняемый файл
18
orte/test/system/mapr.py
Исполняемый файл
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
# input comes from STDIN (standard input)
|
||||
for line in sys.stdin:
|
||||
# remove leading and trailing whitespace
|
||||
line = line.strip()
|
||||
# split the line into words
|
||||
words = line.split()
|
||||
# increase counters
|
||||
for word in words:
|
||||
# write the results to STDOUT (standard output);
|
||||
# what we output here will be the input for the
|
||||
# Reduce step, i.e. the input for reducer.py
|
||||
#
|
||||
# tab-delimited; the trivial word count is 1
|
||||
print '%s\t%s' % (word, 1)
|
@ -1,7 +1,11 @@
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "opal/runtime/opal_progress.h"
|
||||
|
||||
#include "orte/util/proc_info.h"
|
||||
#include "orte/util/name_fns.h"
|
||||
#include "orte/runtime/orte_globals.h"
|
||||
@ -17,29 +21,13 @@ static bool msg_recvd;
|
||||
static opal_buffer_t buf;
|
||||
|
||||
|
||||
static void release_ack(int fd, short event, void *data)
|
||||
{
|
||||
orte_message_event_t *mev = (orte_message_event_t*)data;
|
||||
/* save the buffer */
|
||||
opal_dss.copy_payload(&buf, mev->buffer);
|
||||
msg_recvd = true;
|
||||
OBJ_RELEASE(mev);
|
||||
}
|
||||
|
||||
static void recv_ack(int status, orte_process_name_t* sender,
|
||||
opal_buffer_t* buffer, orte_rml_tag_t tag,
|
||||
void* cbdata)
|
||||
{
|
||||
/* don't process this right away - we need to get out of the recv before
|
||||
* we process the message as it may ask us to do something that involves
|
||||
* more messaging! Instead, setup an event so that the message gets processed
|
||||
* as soon as we leave the recv.
|
||||
*
|
||||
* The macro makes a copy of the buffer, which we release above - the incoming
|
||||
* buffer, however, is NOT released here, although its payload IS transferred
|
||||
* to the message buffer for later processing
|
||||
*/
|
||||
ORTE_MESSAGE_EVENT(sender, buffer, tag, release_ack);
|
||||
/* save the buffer */
|
||||
opal_dss.copy_payload(&buf, buffer);
|
||||
msg_recvd = true;
|
||||
|
||||
/* repost recv */
|
||||
orte_rml.recv_buffer_nb(ORTE_NAME_WILDCARD, MY_TAG,
|
||||
@ -98,7 +86,10 @@ main(int argc, char *argv[]){
|
||||
orte_rml.recv_buffer_nb(ORTE_NAME_WILDCARD, MY_TAG,
|
||||
ORTE_RML_NON_PERSISTENT, recv_ack, NULL);
|
||||
|
||||
ORTE_PROGRESSED_WAIT(msg_recvd, 0, 1);
|
||||
while (!msg_recvd) {
|
||||
opal_progress();
|
||||
}
|
||||
|
||||
opal_output(0, "%s Ring %d completed", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), j);
|
||||
} else {
|
||||
/* wait for msg */
|
||||
@ -107,7 +98,10 @@ main(int argc, char *argv[]){
|
||||
orte_rml.recv_buffer_nb(ORTE_NAME_WILDCARD, MY_TAG,
|
||||
ORTE_RML_NON_PERSISTENT, recv_ack, NULL);
|
||||
|
||||
ORTE_PROGRESSED_WAIT(msg_recvd, 0, 1);
|
||||
while (!msg_recvd) {
|
||||
opal_progress();
|
||||
}
|
||||
|
||||
/* send it along */
|
||||
if (0 > (rc = orte_rml.send_buffer(&peer, &buf, MY_TAG, 0))) {
|
||||
opal_output(0, "%s error sending to %s %s\n", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
||||
|
@ -12,13 +12,20 @@
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
orte_grpcomm_collective_t *coll;
|
||||
|
||||
if (ORTE_SUCCESS != orte_init(&argc, &argv, ORTE_PROC_NON_MPI)) {
|
||||
fprintf(stderr, "Failed orte_init\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
orte_grpcomm.barrier();
|
||||
orte_grpcomm.barrier();
|
||||
coll = OBJ_NEW(orte_grpcomm_collective_t);
|
||||
coll->id = orte_process_info.peer_modex;
|
||||
orte_grpcomm.barrier(coll);
|
||||
|
||||
coll->id = orte_process_info.peer_fini_barrier;
|
||||
orte_grpcomm.barrier(coll);
|
||||
OBJ_RELEASE(coll);
|
||||
|
||||
if (ORTE_SUCCESS != orte_finalize()) {
|
||||
fprintf(stderr, "Failed orte_finalize\n");
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "opal/class/opal_list.h"
|
||||
#include "opal/mca/sysinfo/sysinfo_types.h"
|
||||
#include "opal/util/opal_environ.h"
|
||||
|
||||
#include "orte/util/proc_info.h"
|
||||
@ -23,16 +22,6 @@ int main(int argc, char* argv[])
|
||||
int rc, i, restart=-1;
|
||||
char hostname[512], *rstrt;
|
||||
pid_t pid;
|
||||
char *keys[] = {
|
||||
OPAL_SYSINFO_CPU_TYPE,
|
||||
OPAL_SYSINFO_CPU_MODEL,
|
||||
OPAL_SYSINFO_NUM_CPUS,
|
||||
OPAL_SYSINFO_MEM_SIZE,
|
||||
NULL
|
||||
};
|
||||
opal_list_t values;
|
||||
opal_list_item_t *item;
|
||||
opal_sysinfo_value_t *sys;
|
||||
|
||||
if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_NON_MPI))) {
|
||||
fprintf(stderr, "orte_nodename: couldn't init orte - error code %d\n", rc);
|
||||
@ -46,21 +35,8 @@ int main(int argc, char* argv[])
|
||||
gethostname(hostname, 512);
|
||||
pid = getpid();
|
||||
|
||||
OBJ_CONSTRUCT(&values, opal_list_t);
|
||||
orte_ess.query_sys_info(NULL, keys, &values);
|
||||
|
||||
printf("orte_nodename: Node %s Name %s Pid %ld Restarts: %d Num info %d\n",
|
||||
hostname, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), (long)pid,
|
||||
restart, (int)opal_list_get_size(&values));
|
||||
while (NULL != (item = opal_list_remove_first(&values))) {
|
||||
sys = (opal_sysinfo_value_t*)item;
|
||||
if (OPAL_STRING == sys->type) {
|
||||
printf("\t%s: %s\n", sys->key, sys->data.str);
|
||||
} else {
|
||||
printf("\t%s: %d\n", sys->key, (int)sys->data.i64);
|
||||
|
||||
}
|
||||
}
|
||||
printf("orte_nodename: Node %s Name %s Pid %ld Restarts: %d\n",
|
||||
hostname, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), (long)pid, restart);
|
||||
|
||||
for (i=0; NULL != environ[i]; i++) {
|
||||
if (0 == strncmp(environ[i], "OMPI_MCA", strlen("OMPI_MCA"))) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/mca/event/event.h"
|
||||
|
||||
#include "orte/runtime/orte_globals.h"
|
||||
#include "orte/runtime/runtime.h"
|
||||
@ -40,7 +41,9 @@ int main(int argc, char* argv[])
|
||||
orte_sensor.start(ORTE_JOBID_INVALID);
|
||||
|
||||
/* just sit here, letting the sensors run */
|
||||
opal_event_dispatch(orte_event_base);
|
||||
while (orte_event_base_active) {
|
||||
opal_event_loop(orte_event_base, OPAL_EVLOOP_ONCE);
|
||||
}
|
||||
|
||||
orte_finalize();
|
||||
return 0;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "opal/mca/event/event.h"
|
||||
#include "orte/runtime/orte_globals.h"
|
||||
#include "orte/util/name_fns.h"
|
||||
#include "orte/runtime/runtime.h"
|
||||
@ -22,7 +23,9 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
opal_output(0, "%s RUNNING", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
|
||||
|
||||
opal_event_dispatch(orte_event_base);
|
||||
while (orte_event_base_active) {
|
||||
opal_event_loop(orte_event_base, OPAL_EVLOOP_ONCE);
|
||||
}
|
||||
|
||||
orte_finalize();
|
||||
|
||||
|
38
orte/test/system/red.py
Исполняемый файл
38
orte/test/system/red.py
Исполняемый файл
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from operator import itemgetter
|
||||
import sys
|
||||
|
||||
words = []
|
||||
cnt = []
|
||||
|
||||
# input comes from STDIN
|
||||
for line in sys.stdin:
|
||||
# remove leading and trailing whitespace
|
||||
line = line.strip()
|
||||
|
||||
# parse the input we got from mapper.py
|
||||
word, count = line.split('\t', 1)
|
||||
|
||||
# convert count (currently a string) to int
|
||||
try:
|
||||
count = int(count)
|
||||
except ValueError:
|
||||
# count was not a number, so silently
|
||||
# ignore/discard this line
|
||||
continue
|
||||
|
||||
# Add the word to the list count times
|
||||
try:
|
||||
n = words.index(word)
|
||||
cnt[n] += count
|
||||
except ValueError:
|
||||
words.append(word)
|
||||
cnt.append(count)
|
||||
|
||||
# output the final count
|
||||
print 'Final word count:'
|
||||
n=0
|
||||
for wrd in words:
|
||||
print '%s\t%d' % (wrd, cnt[n])
|
||||
n += 1
|
82
orte/test/system/reducer.c
Обычный файл
82
orte/test/system/reducer.c
Обычный файл
@ -0,0 +1,82 @@
|
||||
/* -*- C -*-
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "orte/constants.h"
|
||||
|
||||
#include "opal/class/opal_list.h"
|
||||
#include "opal/util/argv.h"
|
||||
|
||||
#include "orte/runtime/runtime.h"
|
||||
|
||||
typedef struct {
|
||||
opal_list_item_t super;
|
||||
char *word;
|
||||
int count;
|
||||
} word_count_t;
|
||||
OBJ_CLASS_INSTANCE(word_count_t,
|
||||
opal_list_item_t,
|
||||
NULL, NULL);
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char text[100];
|
||||
opal_list_t words;
|
||||
word_count_t *cnt;
|
||||
char **incnt;
|
||||
bool found;
|
||||
opal_list_item_t *item;
|
||||
|
||||
if (ORTE_SUCCESS != orte_init(&argc, &argv, ORTE_PROC_NON_MPI)) {
|
||||
fprintf(stderr, "Failed orte_init\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
OBJ_CONSTRUCT(&words, opal_list_t);
|
||||
while (fgets(text, sizeof(text), stdin)) {
|
||||
/* remove trailing newline */
|
||||
if ('\n' == text[strlen(text)-1]) {
|
||||
text[strlen(text)-1] = '\0';
|
||||
}
|
||||
incnt = opal_argv_split(text, '\t');
|
||||
found = false;
|
||||
if (opal_argv_count(incnt) < 2) {
|
||||
opal_output(0, "INCORRECT WORD SPLIT: %s", text);
|
||||
opal_argv_free(incnt);
|
||||
continue;
|
||||
}
|
||||
for (item = opal_list_get_first(&words);
|
||||
item != opal_list_get_end(&words);
|
||||
item = opal_list_get_next(item)) {
|
||||
cnt = (word_count_t*)item;
|
||||
if (0 == strcmp(cnt->word, incnt[0])) {
|
||||
cnt->count += atoi(incnt[1]);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
cnt = OBJ_NEW(word_count_t);
|
||||
cnt->word = strdup(incnt[0]);
|
||||
cnt->count = atoi(incnt[1]);
|
||||
opal_list_append(&words, &cnt->super);
|
||||
}
|
||||
opal_argv_free(incnt);
|
||||
}
|
||||
|
||||
fprintf(stdout, "FINAL COUNT:\n");
|
||||
while (NULL != (item = opal_list_remove_first(&words))) {
|
||||
cnt = (word_count_t*)item;
|
||||
fprintf(stdout, "%s: %d\n", cnt->word, cnt->count);
|
||||
OBJ_RELEASE(item);
|
||||
}
|
||||
OBJ_DESTRUCT(&words);
|
||||
|
||||
if (ORTE_SUCCESS != orte_finalize()) {
|
||||
fprintf(stderr, "Failed orte_finalize\n");
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -17,6 +17,8 @@
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/mca/event/event.h"
|
||||
|
||||
#include "orte/runtime/orte_globals.h"
|
||||
|
||||
int called = 0;
|
||||
|
||||
#define NEVENT 2000
|
||||
@ -76,7 +78,9 @@ int main(int argc, char **argv)
|
||||
opal_event_evtimer_add(ev[i], &tv);
|
||||
}
|
||||
|
||||
opal_event_dispatch(orte_event_base);
|
||||
while (orte_event_base_active) {
|
||||
opal_event_loop(orte_event_base, OPAL_EVLOOP_ONCE);
|
||||
}
|
||||
|
||||
opal_finalize();
|
||||
return (called < NEVENT);
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user