version 1.1, 1999/12/03 07:39:11 |
version 1.39, 2016/08/24 05:33:58 |
|
|
/* $OpenXM: OpenXM/src/asir99/io/ox.c,v 1.7 1999/11/19 04:15:49 noro Exp $ */ |
/* |
|
* Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED |
|
* All rights reserved. |
|
* |
|
* FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited, |
|
* non-exclusive and royalty-free license to use, copy, modify and |
|
* redistribute, solely for non-commercial and non-profit purposes, the |
|
* computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and |
|
* conditions of this Agreement. For the avoidance of doubt, you acquire |
|
* only a limited right to use the SOFTWARE hereunder, and FLL or any |
|
* third party developer retains all rights, including but not limited to |
|
* copyrights, in and to the SOFTWARE. |
|
* |
|
* (1) FLL does not grant you a license in any way for commercial |
|
* purposes. You may use the SOFTWARE only for non-commercial and |
|
* non-profit purposes only, such as academic, research and internal |
|
* business use. |
|
* (2) The SOFTWARE is protected by the Copyright Law of Japan and |
|
* international copyright treaties. If you make copies of the SOFTWARE, |
|
* with or without modification, as permitted hereunder, you shall affix |
|
* to all such copies of the SOFTWARE the above copyright notice. |
|
* (3) An explicit reference to this SOFTWARE and its copyright owner |
|
* shall be made on your publication or presentation in any form of the |
|
* results obtained by use of the SOFTWARE. |
|
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
|
* e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification |
|
* for such modification or the source code of the modified part of the |
|
* SOFTWARE. |
|
* |
|
* THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL |
|
* MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND |
|
* EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS |
|
* FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES' |
|
* RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY |
|
* MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY. |
|
* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, |
|
* OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY |
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL |
|
* DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES |
|
* ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES |
|
* FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY |
|
* DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF |
|
* SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART |
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
|
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
|
* $OpenXM: OpenXM_contrib2/asir2000/io/ox.c,v 1.38 2016/08/24 00:52:50 noro Exp $ |
|
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
#include "signal.h" |
#include "wsio.h" |
#include "wsio.h" |
#include "ox.h" |
#include "ox.h" |
|
|
#define ISIZ sizeof(int) |
#define ISIZ sizeof(int) |
|
|
void ox_flush_stream(),ox_write_int(),ox_write_cmo(); |
|
void ox_read_int(),ox_read_cmo(); |
|
void mclist_to_mc(); |
|
void ox_read_local(); |
|
|
|
extern Obj VOIDobj; |
extern Obj VOIDobj; |
|
|
|
extern int nserver_102, myrank_102; |
extern int ox_need_conv; |
extern int ox_need_conv; |
extern int ox_usr1_sent, ox_int_received, critical_when_signal; |
int ox_usr1_sent, ox_int_received, critical_when_signal; |
unsigned int ox_serial; |
unsigned int ox_serial; |
int ox_flushing; |
int ox_flushing; |
int ox_batch; |
int ox_batch; |
int ox_check=1; |
int ox_check=1; |
jmp_buf ox_env; |
int ox_exchange_mathcap=1; |
|
JMP_BUF ox_env; |
|
|
MATHCAP my_mathcap; |
MATHCAP my_mathcap; |
|
|
|
|
unsigned int *smcap; |
unsigned int *smcap; |
int noxcap; |
int noxcap; |
struct oxcap *oxcap; |
struct oxcap *oxcap; |
|
int no_ox_reset; |
}; |
}; |
|
|
struct oxcap *my_oxcap; |
struct oxcap *my_oxcap; |
Line 45 static struct mathcap my_mc; |
|
Line 91 static struct mathcap my_mc; |
|
static struct mathcap *remote_mc; |
static struct mathcap *remote_mc; |
static int remote_mc_len; |
static int remote_mc_len; |
|
|
void ox_resetenv(s) |
void mclist_to_mc(LIST mclist,struct mathcap *mc); |
char *s; |
Obj asir_pop_one(); |
|
void asir_push_one(Obj); |
|
|
|
#if defined(VISUAL) || defined(__MINGW32__) |
|
/* XXX : mainly used in engine2000/io.c, but declared here */ |
|
typedef void *HANDLE; |
|
HANDLE hStreamNotify,hStreamNotify_Ack; |
|
|
|
void cleanup_events() |
{ |
{ |
|
/* ox_watch_stream may be waiting for hStreamNotify_Ack to be set */ |
|
|
|
ResetEvent(hStreamNotify); |
|
SetEvent(hStreamNotify_Ack); |
|
} |
|
#endif |
|
|
|
/* 1 if no_ox_reset, 0 if ox_reset OK, -1 if invalid */ |
|
int no_ox_reset(int s) |
|
{ |
|
if ( remote_mc && s >= 0 && s < remote_mc_len ) |
|
return remote_mc[s].no_ox_reset; |
|
else |
|
return -1; |
|
} |
|
|
|
void ox_resetenv(char *s) |
|
{ |
|
#if defined(VISUAL) || defined(__MINGW32__) |
|
cleanup_events(); |
|
#endif |
fprintf(stderr,"%s\n",s); |
fprintf(stderr,"%s\n",s); |
longjmp(ox_env,1); |
LONGJMP(ox_env,1); |
} |
} |
|
|
static int available_cmo[] = { |
static int available_cmo[] = { |
Line 58 static int available_cmo[] = { |
|
Line 133 static int available_cmo[] = { |
|
CMO_ZZ, CMO_QQ, CMO_ZERO, |
CMO_ZZ, CMO_QQ, CMO_ZERO, |
CMO_DMS_GENERIC, CMO_DMS_OF_N_VARIABLES, |
CMO_DMS_GENERIC, CMO_DMS_OF_N_VARIABLES, |
CMO_RING_BY_NAME, CMO_DISTRIBUTED_POLYNOMIAL, |
CMO_RING_BY_NAME, CMO_DISTRIBUTED_POLYNOMIAL, |
|
CMO_RATIONAL, |
CMO_RECURSIVE_POLYNOMIAL, CMO_UNIVARIATE_POLYNOMIAL, |
CMO_RECURSIVE_POLYNOMIAL, CMO_UNIVARIATE_POLYNOMIAL, |
CMO_INDETERMINATE, |
CMO_INDETERMINATE, |
|
CMO_TREE, CMO_BIGFLOAT32, CMO_COMPLEX, |
0 |
0 |
}; |
}; |
|
|
static int available_sm[] = { |
static int asir_available_sm[] = { |
SM_dupErrors, SM_getsp, SM_popSerializedLocalObject, |
SM_dupErrors, SM_getsp, SM_popSerializedLocalObject, |
SM_popCMO, SM_popString, SM_setName, |
SM_popCMO, SM_popString, SM_pushCMOtag, SM_setName, |
SM_evalName, SM_executeStringByLocalParser, |
SM_evalName, SM_executeStringByLocalParser, |
SM_executeStringByLocalParserInBatchMode, |
SM_executeStringByLocalParserInBatchMode, |
SM_executeFunction, SM_shutdown, SM_pops, |
SM_executeFunction, SM_shutdown, SM_pops, |
Line 74 static int available_sm[] = { |
|
Line 151 static int available_sm[] = { |
|
0 |
0 |
}; |
}; |
|
|
|
static int ox_asir_available_sm[] = { |
|
SM_dupErrors, SM_getsp, SM_popSerializedLocalObject, |
|
SM_popCMO, SM_popString, SM_pushCMOtag, SM_setName, |
|
SM_evalName, SM_executeStringByLocalParser, |
|
SM_executeStringByLocalParserInBatchMode, |
|
SM_executeFunction, SM_shutdown, SM_pops, |
|
SM_mathcap, SM_setMathcap, SM_nop, |
|
SM_beginBlock, SM_endBlock, SM_executeFunctionSync, |
|
SM_set_rank_102, SM_tcp_accept_102, SM_tcp_connect_102, SM_reset_102, |
|
SM_bcast_102, SM_reduce_102, |
|
0 |
|
}; |
|
|
|
static int ox_plot_available_sm[] = { |
|
SM_dupErrors, SM_getsp, SM_popSerializedLocalObject, |
|
SM_popCMO, SM_popString, SM_setName, |
|
SM_evalName, SM_executeStringByLocalParser, |
|
SM_executeFunction, SM_shutdown, SM_pops, |
|
SM_mathcap, SM_setMathcap, SM_nop, |
|
0 |
|
}; |
|
|
/* |
/* |
mathcap = |
mathcap = |
[ |
[ |
Line 92 void create_my_mathcap(char *system) |
|
Line 191 void create_my_mathcap(char *system) |
|
NODE n,n0; |
NODE n,n0; |
int i,k; |
int i,k; |
STRING str; |
STRING str; |
LIST sname,smlist,oxlist,cmolist,asirlist,oxtag,oxasir,r; |
LIST sname,smlist,oxlist,cmolist,asirlist,oxasir,r; |
USINT tag,t,t1; |
USINT tag,t,t1; |
|
|
if ( my_mathcap ) |
if ( my_mathcap ) |
Line 102 void create_my_mathcap(char *system) |
|
Line 201 void create_my_mathcap(char *system) |
|
MKUSINT(t,OX_VERSION); |
MKUSINT(t,OX_VERSION); |
n0 = mknode(2,t,str); MKLIST(sname,n0); |
n0 = mknode(2,t,str); MKLIST(sname,n0); |
|
|
/* cmo tag */ |
/* sm tag */ |
for ( n0 = 0, i = 0; k = available_sm[i]; i++ ) { |
n0 = 0; |
NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t; |
if ( !strcmp(system,"asir") ) { |
|
for ( i = 0; k = asir_available_sm[i]; i++ ) { |
|
NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t; |
|
} |
|
} else if ( !strcmp(system,"ox_asir") ) { |
|
for ( i = 0; k = ox_asir_available_sm[i]; i++ ) { |
|
NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t; |
|
} |
|
NEXT(n) = 0; |
|
} else if ( !strcmp(system,"ox_plot") ) { |
|
for ( i = 0; k = ox_plot_available_sm[i]; i++ ) { |
|
NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t; |
|
} |
|
NEXT(n) = 0; |
} |
} |
NEXT(n) = 0; MKLIST(smlist,n0); |
MKLIST(smlist,n0); |
|
|
/* creation of [OX_DATA,CMO list] */ |
/* creation of [OX_DATA,CMO list] */ |
/* ox tag */ |
/* ox tag */ |
Line 185 void store_remote_mathcap(int s,MATHCAP mc) |
|
Line 297 void store_remote_mathcap(int s,MATHCAP mc) |
|
|
|
void mclist_to_mc(LIST mclist,struct mathcap *mc) |
void mclist_to_mc(LIST mclist,struct mathcap *mc) |
{ |
{ |
int id,l,i,j; |
int l,i,j; |
NODE n,t,oxcmo,ox,cap; |
NODE n,t,oxcmo,cap; |
int *ptr; |
int *ptr; |
|
|
/* |
/* |
Line 198 void mclist_to_mc(LIST mclist,struct mathcap *mc) |
|
Line 310 void mclist_to_mc(LIST mclist,struct mathcap *mc) |
|
[o2,[n21,n22,...]], |
[o2,[n21,n22,...]], |
... |
... |
] |
] |
|
(optional)[s1,s2,...] (no_ox_reset) |
] |
] |
*/ |
*/ |
n = BDY(mclist); |
n = BDY(mclist); |
Line 230 void mclist_to_mc(LIST mclist,struct mathcap *mc) |
|
Line 343 void mclist_to_mc(LIST mclist,struct mathcap *mc) |
|
for ( t = cap, ptr = mc->oxcap[j].cap, i = 0; i < l; t = NEXT(t), i++ ) |
for ( t = cap, ptr = mc->oxcap[j].cap, i = 0; i < l; t = NEXT(t), i++ ) |
ptr[i] = BDY((USINT)BDY(t)); |
ptr[i] = BDY((USINT)BDY(t)); |
} |
} |
|
/* check of no_ox_reset */ |
|
mc->no_ox_reset = 0; |
|
n = BDY(mclist); |
|
if ( length(n) >= 4 ) { |
|
t = BDY((LIST)ARG3(n)); |
|
for ( ; t; t = NEXT(t) ) |
|
if ( !strcmp(BDY((STRING)BDY(t)),"no_ox_reset") ) |
|
mc->no_ox_reset = 1; |
|
} |
} |
} |
|
|
int check_sm_by_mc(s,smtag) |
int check_sm_by_mc(int s,unsigned int smtag) |
int s; |
|
unsigned int smtag; |
|
{ |
{ |
struct mathcap *rmc; |
struct mathcap *rmc; |
int nsmcap,i; |
int nsmcap,i; |
Line 257 unsigned int smtag; |
|
Line 377 unsigned int smtag; |
|
return 1; |
return 1; |
} |
} |
|
|
int check_by_mc(s,oxtag,cmotag) |
int check_by_mc(int s,unsigned int oxtag,unsigned int cmotag) |
int s; |
|
unsigned int oxtag,cmotag; |
|
{ |
{ |
struct mathcap *rmc; |
struct mathcap *rmc; |
int noxcap,ncap,i,j; |
int noxcap,ncap,i,j; |
Line 297 void begin_critical() { |
|
Line 415 void begin_critical() { |
|
void end_critical() { |
void end_critical() { |
critical_when_signal = 0; |
critical_when_signal = 0; |
if ( ox_usr1_sent ) { |
if ( ox_usr1_sent ) { |
ox_usr1_sent = 0; ox_usr1_handler(); |
ox_usr1_sent = 0; |
|
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
ox_usr1_handler(SIGUSR1); |
|
#else |
|
ox_usr1_handler(0); |
|
#endif |
} |
} |
if ( ox_int_received ) { |
if ( ox_int_received ) { |
ox_int_received = 0; int_handler(SIGINT); |
ox_int_received = 0; int_handler(SIGINT); |
} |
} |
} |
} |
|
|
void ox_usr1_handler(sig) |
extern NODE user_int_handler; |
int sig; |
|
|
void ox_usr1_handler(int sig) |
{ |
{ |
extern jmp_buf env; |
NODE t; |
unsigned int cmd; |
|
|
|
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
signal(SIGUSR1,ox_usr1_handler); |
set_signal_for_restart(SIGUSR1,ox_usr1_handler); |
#endif |
#endif |
if ( critical_when_signal ) { |
if ( critical_when_signal ) { |
fprintf(stderr,"usr1 : critical\n"); |
fprintf(stderr,"usr1 : critical\n"); |
ox_usr1_sent = 1; |
ox_usr1_sent = 1; |
} else { |
} else { |
ox_flushing = 1; |
ox_flushing = 1; |
|
if ( user_int_handler ) { |
|
fprintf(stderr, |
|
"usr1 : calling the registered exception handlers..."); |
|
for ( t = user_int_handler; t; t = NEXT(t) ) |
|
bevalf((FUNC)BDY(t),0); |
|
fprintf(stderr, "done.\n"); |
|
} |
ox_resetenv("usr1 : return to toplevel by SIGUSR1"); |
ox_resetenv("usr1 : return to toplevel by SIGUSR1"); |
} |
} |
} |
} |
|
|
void clear_readbuffer() |
void clear_readbuffer() |
{ |
{ |
char c; |
|
fd_set r,w,e; |
|
struct timeval interval; |
|
int n,sock; |
|
|
|
#if defined(linux) |
#if defined(linux) |
iofp[0].in->_IO_read_ptr = iofp[0].in->_IO_read_end; |
iofp[0].in->_IO_read_ptr = iofp[0].in->_IO_read_end; |
#elif defined(__FreeBSD__) |
#elif defined(__FreeBSD__) |
Line 360 void wait_for_data(int s) |
|
Line 485 void wait_for_data(int s) |
|
{ |
{ |
return; |
return; |
} |
} |
|
|
|
void wait_for_data_102(int rank) |
|
{ |
|
return; |
|
} |
#else |
#else |
int ox_data_is_available(int s) |
int ox_data_is_available(int s) |
{ |
{ |
Line 372 void wait_for_data(int s) |
|
Line 502 void wait_for_data(int s) |
|
int sock; |
int sock; |
|
|
if ( !FP_DATA_IS_AVAILABLE(iofp[s].in) ) { |
if ( !FP_DATA_IS_AVAILABLE(iofp[s].in) ) { |
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
sock = iofp[s].in->fildes; |
sock = iofp[s].in->fildes; |
FD_ZERO(&r); |
FD_ZERO(&r); |
FD_SET(sock,&r); |
FD_SET((unsigned int)sock,&r); |
select(0,&r,NULL,NULL,NULL); |
select(0,&r,NULL,NULL,NULL); |
#else |
#else |
sock = fileno(iofp[s].in); |
sock = fileno(iofp[s].in); |
Line 385 void wait_for_data(int s) |
|
Line 515 void wait_for_data(int s) |
|
#endif |
#endif |
} |
} |
} |
} |
|
|
|
void wait_for_data_102(int rank) |
|
{ |
|
fd_set r; |
|
int sock; |
|
|
|
if ( !FP_DATA_IS_AVAILABLE(iofp_102[rank].in) ) { |
|
#if defined(VISUAL) || defined(__MINGW32__) |
|
sock = iofp_102[rank].in->fildes; |
|
FD_ZERO(&r); |
|
FD_SET((unsigned int)sock,&r); |
|
select(0,&r,NULL,NULL,NULL); |
|
#else |
|
sock = fileno(iofp_102[rank].in); |
|
FD_ZERO(&r); |
|
FD_SET(sock,&r); |
|
select(FD_SETSIZE,&r,NULL,NULL,NULL); |
#endif |
#endif |
|
} |
|
} |
|
#endif |
|
|
void ox_send_data(int s,pointer p) |
void ox_send_data(int s,pointer p) |
{ |
{ |
if ( ox_check && !ox_check_cmo(s,(Obj)p) ) |
ERR err; |
error("ox_send_data : Mathcap violation"); |
|
|
if ( ox_check && !ox_check_cmo(s,(Obj)p) ) { |
|
create_error(&err,ox_serial,"ox_send_data : Mathcap violation",0); |
|
p = (pointer)err; |
|
} |
begin_critical(); |
begin_critical(); |
ox_write_int(s,OX_DATA); |
ox_write_int(s,OX_DATA); |
ox_write_int(s,ox_serial++); |
ox_write_int(s,ox_serial++); |
Line 399 void ox_send_data(int s,pointer p) |
|
Line 553 void ox_send_data(int s,pointer p) |
|
end_critical(); |
end_critical(); |
} |
} |
|
|
|
void ox_send_data_102(int rank,pointer p) |
|
{ |
|
ERR err; |
|
|
|
begin_critical(); |
|
ox_write_int_102(rank,OX_DATA); |
|
ox_write_int_102(rank,ox_serial++); |
|
ox_write_cmo_102(rank,p); |
|
ox_flush_stream_102(rank); |
|
end_critical(); |
|
} |
|
|
|
void ox_bcast_102(int root) |
|
{ |
|
Obj data; |
|
int r,mask,id,src,dst; |
|
|
|
r = myrank_102-root; |
|
if ( r == 0 ) |
|
data = (Obj)asir_pop_one(); |
|
|
|
if ( r < 0 ) r += nserver_102; |
|
for ( mask = 1; mask < nserver_102; mask <<= 1 ) |
|
if ( r&mask ) { |
|
src = myrank_102-mask; |
|
if ( src < 0 ) src += nserver_102; |
|
ox_recv_102(src,&id,&data); |
|
break; |
|
} |
|
for ( mask >>= 1; mask > 0; mask >>= 1 ) |
|
if ( (r+mask) < nserver_102 ) { |
|
dst = myrank_102+mask; |
|
if ( dst >= nserver_102 ) dst -= nserver_102; |
|
ox_send_data_102(dst,data); |
|
} |
|
asir_push_one(data); |
|
} |
|
|
|
/* func : an arithmetic funcion func(vl,a,b,*c) */ |
|
|
|
void ox_reduce_102(int root,void (*func)()) |
|
{ |
|
Obj data,data0,t; |
|
int r,mask,id,src,dst; |
|
|
|
r = myrank_102-root; |
|
if ( r < 0 ) r += nserver_102; |
|
data = (Obj)asir_pop_one(); |
|
for ( mask = 1; mask < nserver_102; mask <<= 1 ) |
|
if ( r&mask ) { |
|
dst = (r-mask)+root; |
|
if ( dst >= nserver_102 ) dst -= nserver_102; |
|
ox_send_data_102(dst,data); |
|
break; |
|
} else { |
|
src = r+mask; |
|
if ( src < nserver_102 ) { |
|
src += root; |
|
if ( src >= nserver_102 ) src -= nserver_102; |
|
ox_recv_102(src,&id,&data0); |
|
(*func)(CO,data,data0,&t); data = t; |
|
} |
|
} |
|
asir_push_one(r?0:data); |
|
} |
|
|
void ox_send_cmd(int s,int id) |
void ox_send_cmd(int s,int id) |
{ |
{ |
if ( ox_check && !check_sm_by_mc(s,id) ) |
if ( ox_check && !check_sm_by_mc(s,id) ) |
Line 420 void ox_send_sync(int s) |
|
Line 640 void ox_send_sync(int s) |
|
end_critical(); |
end_critical(); |
} |
} |
|
|
|
void ox_send_sync_102(int rank) |
|
{ |
|
begin_critical(); |
|
ox_write_int_102(rank,OX_SYNC_BALL); |
|
ox_write_int_102(rank,ox_serial++); |
|
ox_flush_stream_102(rank); |
|
end_critical(); |
|
} |
|
|
void ox_send_local_data(int s,Obj p) |
void ox_send_local_data(int s,Obj p) |
{ |
{ |
begin_critical(); |
begin_critical(); |
ox_write_int(s,OX_LOCAL_OBJECT_ASIR); |
ox_write_int(s,OX_LOCAL_OBJECT_ASIR); |
ox_write_int(s,ox_serial++); |
ox_write_int(s,ox_serial++); |
ox_write_int(s,ASIR_OBJ); |
ox_write_int(s,ASIR_OBJ); |
saveobj(iofp[s].out,p); |
saveobj((FILE *)iofp[s].out,p); |
ox_flush_stream(s); |
ox_flush_stream(s); |
end_critical(); |
end_critical(); |
} |
} |
|
|
|
void ox_send_local_data_102(int rank,Obj p) |
|
{ |
|
begin_critical(); |
|
ox_write_int_102(rank,OX_LOCAL_OBJECT_ASIR); |
|
ox_write_int_102(rank,ox_serial++); |
|
ox_write_int_102(rank,ASIR_OBJ); |
|
saveobj((FILE *)iofp_102[rank].out,p); |
|
ox_flush_stream_102(rank); |
|
end_critical(); |
|
} |
|
|
void ox_send_local_ring(int s,VL vl) |
void ox_send_local_ring(int s,VL vl) |
{ |
{ |
begin_critical(); |
begin_critical(); |
ox_write_int(s,OX_LOCAL_OBJECT_ASIR); |
ox_write_int(s,OX_LOCAL_OBJECT_ASIR); |
ox_write_int(s,ox_serial++); |
ox_write_int(s,ox_serial++); |
ox_write_int(s,ASIR_VL); |
ox_write_int(s,ASIR_VL); |
savevl(iofp[s].out,vl); |
savevl((FILE *)iofp[s].out,vl); |
ox_flush_stream(s); |
ox_flush_stream(s); |
end_critical(); |
end_critical(); |
} |
} |
|
|
unsigned int ox_recv(int s, int *id, pointer *p) |
void ox_send_local_ring_102(int rank,VL vl) |
{ |
{ |
|
begin_critical(); |
|
ox_write_int_102(rank,OX_LOCAL_OBJECT_ASIR); |
|
ox_write_int_102(rank,ox_serial++); |
|
ox_write_int_102(rank,ASIR_VL); |
|
savevl((FILE *)iofp_102[rank].out,vl); |
|
ox_flush_stream_102(rank); |
|
end_critical(); |
|
} |
|
|
|
unsigned int ox_recv(int s, int *id, Obj *p) |
|
{ |
unsigned int cmd,serial; |
unsigned int cmd,serial; |
USINT ui; |
USINT ui; |
|
|
Line 455 unsigned int ox_recv(int s, int *id, pointer *p) |
|
Line 706 unsigned int ox_recv(int s, int *id, pointer *p) |
|
case OX_COMMAND: |
case OX_COMMAND: |
ox_read_int(s,&cmd); |
ox_read_int(s,&cmd); |
MKUSINT(ui,cmd); |
MKUSINT(ui,cmd); |
*p = (pointer)ui; |
*p = (Obj)ui; |
break; |
break; |
case OX_DATA: |
case OX_DATA: |
ox_read_cmo(s,p); |
ox_read_cmo(s,p); |
Line 471 unsigned int ox_recv(int s, int *id, pointer *p) |
|
Line 722 unsigned int ox_recv(int s, int *id, pointer *p) |
|
return serial; |
return serial; |
} |
} |
|
|
void ox_get_result(s,rp) |
unsigned int ox_recv_102(int rank, int *id, Obj *p) |
int s; |
|
Obj *rp; |
|
{ |
{ |
|
unsigned int cmd,serial; |
|
USINT ui; |
|
|
|
wait_for_data_102(rank); |
|
begin_critical(); |
|
ox_read_int_102(rank,id); |
|
ox_read_int_102(rank,&serial); |
|
switch ( *id ) { |
|
case OX_COMMAND: |
|
ox_read_int_102(rank,&cmd); |
|
MKUSINT(ui,cmd); |
|
*p = (Obj)ui; |
|
break; |
|
case OX_DATA: |
|
ox_read_cmo_102(rank,p); |
|
break; |
|
case OX_LOCAL_OBJECT_ASIR: |
|
ox_read_local_102(rank,p); |
|
break; |
|
default: |
|
*p = 0; |
|
break; |
|
} |
|
end_critical(); |
|
return serial; |
|
} |
|
|
|
void ox_get_result(int s,Obj *rp) |
|
{ |
int id; |
int id; |
Obj obj,r; |
Obj obj,r; |
int level; |
int level; |
|
|
level = 0; |
level = 0; |
r = 0; |
r = 0; |
do { |
do { |
ox_recv(s,&id,(pointer *)&obj); |
ox_recv(s,&id,&obj); |
if ( id == OX_COMMAND ) { |
if ( id == OX_COMMAND ) { |
switch ( ((USINT)obj)->body ) { |
switch ( ((USINT)obj)->body ) { |
case SM_beginBlock: |
case SM_beginBlock: |
|
|
void ox_read_int(int s, int *n) |
void ox_read_int(int s, int *n) |
{ |
{ |
ox_need_conv = iofp[s].conv; |
ox_need_conv = iofp[s].conv; |
read_int(iofp[s].in,n); |
read_int((FILE *)iofp[s].in,n); |
} |
} |
|
|
|
void ox_read_int_102(int rank, int *n) |
|
{ |
|
ox_need_conv = iofp_102[rank].conv; |
|
read_int((FILE *)iofp_102[rank].in,n); |
|
} |
|
|
void ox_read_cmo(int s, Obj *rp) |
void ox_read_cmo(int s, Obj *rp) |
{ |
{ |
ox_need_conv = iofp[s].conv; |
ox_need_conv = iofp[s].conv; |
read_cmo(iofp[s].in,rp); |
read_cmo((FILE *)iofp[s].in,rp); |
} |
} |
|
|
|
void ox_read_cmo_102(int rank, Obj *rp) |
|
{ |
|
ox_need_conv = iofp_102[rank].conv; |
|
read_cmo((FILE *)iofp_102[rank].in,rp); |
|
} |
|
|
|
|
void ox_read_local(int s, Obj *rp) |
void ox_read_local(int s, Obj *rp) |
{ |
{ |
int id; |
int id; |
|
|
ox_need_conv = iofp[s].conv; |
ox_need_conv = iofp[s].conv; |
read_int(iofp[s].in,&id); |
read_int((FILE *)iofp[s].in,&id); |
switch ( id ) { |
switch ( id ) { |
case ASIR_VL: |
case ASIR_VL: |
loadvl(iofp[s].in); |
loadvl((FILE *)iofp[s].in); |
*rp = VOIDobj; |
*rp = VOIDobj; |
break; |
break; |
case ASIR_OBJ: |
case ASIR_OBJ: |
loadobj(iofp[s].in,rp); |
loadobj((FILE *)iofp[s].in,rp); |
break; |
break; |
default: |
default: |
error("ox_read_local : unsupported id"); |
error("ox_read_local : unsupported id"); |
Line 529 void ox_read_local(int s, Obj *rp) |
|
Line 820 void ox_read_local(int s, Obj *rp) |
|
} |
} |
} |
} |
|
|
|
void ox_read_local_102(int rank, Obj *rp) |
|
{ |
|
int id; |
|
|
|
ox_need_conv = iofp_102[rank].conv; |
|
read_int((FILE *)iofp_102[rank].in,&id); |
|
switch ( id ) { |
|
case ASIR_VL: |
|
loadvl((FILE *)iofp_102[rank].in); |
|
*rp = VOIDobj; |
|
break; |
|
case ASIR_OBJ: |
|
loadobj((FILE *)iofp_102[rank].in,rp); |
|
break; |
|
default: |
|
error("ox_read_local_102 : unsupported id"); |
|
break; |
|
} |
|
} |
|
|
void ox_write_int(int s, int n) |
void ox_write_int(int s, int n) |
{ |
{ |
ox_need_conv = iofp[s].conv; |
ox_need_conv = iofp[s].conv; |
write_int(iofp[s].out,&n); |
write_int((FILE *)iofp[s].out,&n); |
} |
} |
|
|
|
void ox_write_int_102(int rank, int n) |
|
{ |
|
ox_need_conv = iofp_102[rank].conv; |
|
write_int((FILE *)iofp_102[rank].out,&n); |
|
} |
|
|
void ox_write_cmo(int s, Obj obj) |
void ox_write_cmo(int s, Obj obj) |
{ |
{ |
ox_need_conv = iofp[s].conv; |
ox_need_conv = iofp[s].conv; |
write_cmo(iofp[s].out,obj); |
write_cmo((FILE *)iofp[s].out,obj); |
} |
} |
|
|
|
void ox_write_cmo_102(int rank, Obj obj) |
|
{ |
|
ox_need_conv = iofp_102[rank].conv; |
|
write_cmo((FILE *)iofp_102[rank].out,obj); |
|
} |
|
|
int ox_check_cmo(int s, Obj obj) |
int ox_check_cmo(int s, Obj obj) |
{ |
{ |
NODE m; |
NODE m; |
Line 549 int ox_check_cmo(int s, Obj obj) |
|
Line 872 int ox_check_cmo(int s, Obj obj) |
|
return 1; |
return 1; |
switch ( OID(obj) ) { |
switch ( OID(obj) ) { |
case O_MATHCAP: case O_STR: case O_ERR: case O_USINT: case O_VOID: |
case O_MATHCAP: case O_STR: case O_ERR: case O_USINT: case O_VOID: |
|
case O_BYTEARRAY: |
return 1; |
return 1; |
case O_P: |
case O_P: |
if ( !check_by_mc(s,OX_DATA,CMO_RECURSIVE_POLYNOMIAL) ) |
if ( !check_by_mc(s,OX_DATA,CMO_RECURSIVE_POLYNOMIAL) ) |
Line 565 int ox_check_cmo(int s, Obj obj) |
|
Line 889 int ox_check_cmo(int s, Obj obj) |
|
case O_DP: |
case O_DP: |
return ox_check_cmo_dp(s,(DP)obj); |
return ox_check_cmo_dp(s,(DP)obj); |
case O_N: |
case O_N: |
if ( NID((Num)obj) == N_Q ) { |
switch ( NID((Num)obj) ) { |
if ( INT((Q)obj) ) |
case N_Q: |
return check_by_mc(s,OX_DATA,CMO_ZZ); |
if ( INT((Q)obj) ) |
else |
return check_by_mc(s,OX_DATA,CMO_ZZ); |
return check_by_mc(s,OX_DATA,CMO_QQ); |
else |
} else |
return check_by_mc(s,OX_DATA,CMO_QQ); |
return 0; |
case N_R: case N_B: case N_C: |
|
return 1; |
|
default: |
|
return 0; |
|
} |
|
break; |
case O_LIST: |
case O_LIST: |
for ( m = BDY((LIST)obj); m; m = NEXT(m) ) |
for ( m = BDY((LIST)obj); m; m = NEXT(m) ) |
if ( !ox_check_cmo(s,(BDY(m))) ) |
if ( !ox_check_cmo(s,(BDY(m))) ) |
return 0; |
return 0; |
return 1; |
return 1; |
|
case O_QUOTE: /* XXX */ |
|
return 1; |
|
case O_MAT: /* MAT is sent as a list */ |
|
return 1; |
default: |
default: |
return 0; |
return 0; |
} |
} |
Line 591 void ox_get_serverinfo(int s, LIST *rp) |
|
Line 924 void ox_get_serverinfo(int s, LIST *rp) |
|
} |
} |
} |
} |
|
|
|
char *ox_get_servername(int s) |
|
{ |
|
return (remote_mc && remote_mc[s].servername)?remote_mc[s].servername:0; |
|
} |
|
|
|
|
int ox_check_cmo_p(int s, P p) |
int ox_check_cmo_p(int s, P p) |
{ |
{ |
DCP dc; |
DCP dc; |
Line 615 int ox_check_cmo_dp(int s, DP p) |
|
Line 954 int ox_check_cmo_dp(int s, DP p) |
|
return 1; |
return 1; |
} |
} |
|
|
void ox_flush_stream(s) |
void ox_flush_stream(int s) |
int s; |
|
{ |
{ |
if ( ox_batch ) |
if ( ox_batch ) |
return; |
return; |
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
if ( _fileno(&iofp[s].out->fp) < 0 ) |
if ( _fileno(&iofp[s].out->fp) < 0 ) |
cflush(iofp[s].out); |
cflush(iofp[s].out); |
else |
else |
|
|
cflush(iofp[s].out); |
cflush(iofp[s].out); |
else |
else |
#endif |
#endif |
fflush(iofp[s].out); |
fflush((FILE *)iofp[s].out); |
} |
} |
|
|
void ox_flush_stream_force(s) |
void ox_flush_stream_force(int s) |
int s; |
|
{ |
{ |
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
if ( _fileno(&iofp[s].out->fp) < 0 ) |
if ( _fileno(&iofp[s].out->fp) < 0 ) |
cflush(iofp[s].out); |
cflush(iofp[s].out); |
else |
else |
|
|
cflush(iofp[s].out); |
cflush(iofp[s].out); |
else |
else |
#endif |
#endif |
fflush(iofp[s].out); |
fflush((FILE *)iofp[s].out); |
|
} |
|
|
|
void ox_flush_stream_102(int rank) |
|
{ |
|
if ( !ox_batch ) |
|
ox_flush_stream_force_102(rank); |
|
} |
|
|
|
void ox_flush_stream_force_102(int rank) |
|
{ |
|
if ( iofp_102[rank].out ) |
|
#if defined(VISUAL) || defined(__MINGW32__) |
|
cflush(iofp_102[rank].out); |
|
#elif MPI |
|
cflush(iofp_102[rank].out); |
|
#else |
|
fflush(iofp_102[rank].out); |
|
#endif |
} |
} |