Subject: Re: [Q] fast integer array sending

From: Kees Everaars <[email-masked]>
Date: Tue, 10 Mar 1998 09:54:38 +0100

Hi Mr Hye-Seon Maeng and everyone

A complete other solution for this problem is solve it by using the 
coordination language Manifold.

In that way it goes as follows:

In a separate coordinator program written in the Manifold language (see the 
file "catch_array.m" below) we set up a connection between a sender of the big 
integer array (probably the outcome of some heavy computational work) and the 
receiver of it (who use it as input for his computational job). (In the  
Manifold coordination language we do this by using the arrow "->"). The sender 
and receiver are both, for example, C programs and they run as threads in a 
multithreaded program.

The separate coordinator program written in the Manifold
 coordination language is shown in the Manifold source file source file 
"catch_array.m" below.

The sender and receiver, both implemented in C, are stored in 
the source file  "catch_array.ato.c" below.

The .m file is compile with the Manifold compiler and the C stuff with the 
normal C compiler and is linked, which results in a multithreaded exectable.
This program can run in a parallel way. 
When you want this program as a distributed application the only thing you 
have to do is specifing in a description file that the sender should be in
multithreaded program A and the receiver in multithreaded program B.
(Thus, there is no need to changed the .m file and the .c file.)
These executables A and B can run in a heterogeneous network
of computers and use the machines you specify in a "machine file".
Thus, from the language point of view, Manifold makes no distinction between
a parallel and distributed application.
(the .m and .c files are the same).

Another nice thing in the "Manifold solution" is the clear separation between 
the coordination part of your problem (sending it from one worker to another 
worker) and the computational side of it (the stuff implemented in the C).

For more information you can have a look at
http://www.cwi.nl/~farhad/manifold.html
When you want a survey of what coordination is and for "what" and
"how" you can use it, keep your eye on the spring issue of the journal 
"Parallel Computing". This time it is a special issue about Coordination.

Good luck with solving your problem.

Regards from Holland, Kees Everaars

-------------------------
The file catch_array.m is
_________________________

manifold send atomic {internal.}.
manifold receive atomic {internal.}.

/***************************************************/
manifold Main
{
  begin:  send -> receive.
}
~
----------------------------
The file "catch_array.ato.c"
----------------------------

#include "AP_interface.h"
#include "debug.h"

#define BOUND 1000

/***************************************************/
void send(void)
{
  int ara[BOUND];
  int i, err;
  AP_Unit u;
  
  for (i = 0; i < BOUND;  i++) {
      ara[i] = i;
  }

  u = AP_FrameIntegerArray(ara, BOUND);                      P(u)
  err = AP_PortPlaceUnit(AP_OUTPUT, u, NULL);                I(err)
  err = AP_DeallocateUnit(u);                                I(err)
}

/***************************************************/
void receive(void)
{
  int arb[BOUND];
  AP_Unit u;
  int i, err;

  err = AP_PortRemoveUnit(AP_INPUT, &u, NULL);                  P(u) I(err)
  err = AP_FetchIntegerArray(u, arb, BOUND);                    I(err)
  err = AP_DeallocateUnit(u);                                   I(err)
  for (i = 0; i < BOUND;  i++) {
    printf("%d ", arb[i]);
  }
  printf("\n");
}

In message <01BD4C16.95A434C0@PAUL > you wrote:
  > 	Hi! everyone.
  > 	I am writing a parallel and distributed program with java.
  > 	In this program, one application on web server machine should communica
  > te with many 
  > 	applets which are downloaded from this web server machine and executed 
  > on the 
  > 	other machines. The application opens socket connection and waits for
  > 	any applet's request. When an applet sends request, the application and
  >  an applet 
  > 	can communicate via socket.
  > 	I used DataInputStream class and DataOutputStream class to write and re
  > ad socket.
  > 	I would like to send big integer array from application to applet and f
  > rom applet to application.
  > 	So I used DataInputStream and DataOutputStream class and its member met
  > hod writeInt(int).
  > 	But it is very slow to send one integer after another. 
  > 	If I want to send 1000 integer array, I have used 
  > 	for (i=0; i<1000; ++i)
  > 	  writeInt(a[i]);
  > 
  > 	I think there might be more powerful method to send integer array via s
  > ocket.
  > 	But I don't know what the method is.
  > 	If you know it, please let me know it. It will be very much help to my 
  > research.
  > 	sincerely yours.
  > 
  > 
  > 	Hye-Seon Maeng 	([email-masked])
  > 
  > 	Parallel Processing System Lab.
  > 	Computer Science Dept.
  > 	Yonsei University Seoul Korea
  >