=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/ox.c,v retrieving revision 1.23 retrieving revision 1.35 diff -u -p -r1.23 -r1.35 --- OpenXM_contrib2/asir2000/io/ox.c 2003/12/10 07:37:40 1.23 +++ OpenXM_contrib2/asir2000/io/ox.c 2015/08/14 13:51:55 1.35 @@ -44,7 +44,7 @@ * 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.22 2003/12/10 05:39:58 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/ox.c,v 1.34 2015/08/08 14:19:42 fujimoto Exp $ */ #include "ca.h" #include "parse.h" @@ -91,9 +91,12 @@ static struct mathcap *remote_mc; static int remote_mc_len; void mclist_to_mc(LIST mclist,struct mathcap *mc); +Obj asir_pop_one(); +void asir_push_one(Obj); -#if defined(VISUAL) +#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() @@ -107,7 +110,7 @@ void cleanup_events() void ox_resetenv(char *s) { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) cleanup_events(); #endif fprintf(stderr,"%s\n",s); @@ -120,9 +123,10 @@ static int available_cmo[] = { CMO_ZZ, CMO_QQ, CMO_ZERO, CMO_DMS_GENERIC, CMO_DMS_OF_N_VARIABLES, CMO_RING_BY_NAME, CMO_DISTRIBUTED_POLYNOMIAL, + CMO_RATIONAL, CMO_RECURSIVE_POLYNOMIAL, CMO_UNIVARIATE_POLYNOMIAL, CMO_INDETERMINATE, - CMO_TREE, + CMO_TREE, CMO_BIGFLOAT, 0 }; @@ -144,8 +148,9 @@ static int ox_asir_available_sm[] = { SM_executeStringByLocalParserInBatchMode, SM_executeFunction, SM_shutdown, SM_pops, SM_mathcap, SM_setMathcap, SM_nop, - SM_beginBlock, SM_endBlock, + 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 }; @@ -391,7 +396,7 @@ void end_critical() { critical_when_signal = 0; if ( ox_usr1_sent ) { ox_usr1_sent = 0; -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) ox_usr1_handler(SIGUSR1); #else ox_usr1_handler(0); @@ -402,11 +407,13 @@ void end_critical() { } } -extern FUNC registered_handler; +extern NODE user_int_handler; void ox_usr1_handler(int sig) { -#if !defined(VISUAL) + NODE t; + +#if !defined(VISUAL) && !defined(__MINGW32__) signal(SIGUSR1,ox_usr1_handler); #endif if ( critical_when_signal ) { @@ -414,10 +421,11 @@ void ox_usr1_handler(int sig) ox_usr1_sent = 1; } else { ox_flushing = 1; - if ( registered_handler ) { + if ( user_int_handler ) { fprintf(stderr, - "usr1 : calling the registered exception handler..."); - bevalf(registered_handler,0); + "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"); @@ -457,6 +465,11 @@ void wait_for_data(int s) { return; } + +void wait_for_data_102(int rank) +{ + return; +} #else int ox_data_is_available(int s) { @@ -469,7 +482,7 @@ void wait_for_data(int s) int sock; if ( !FP_DATA_IS_AVAILABLE(iofp[s].in) ) { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) sock = iofp[s].in->fildes; FD_ZERO(&r); FD_SET((unsigned int)sock,&r); @@ -489,7 +502,7 @@ void wait_for_data_102(int rank) int sock; if ( !FP_DATA_IS_AVAILABLE(iofp_102[rank].in) ) { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) sock = iofp_102[rank].in->fildes; FD_ZERO(&r); FD_SET((unsigned int)sock,&r); @@ -509,7 +522,7 @@ void ox_send_data(int s,pointer p) ERR err; if ( ox_check && !ox_check_cmo(s,(Obj)p) ) { - create_error(&err,ox_serial,"ox_send_data : Mathcap violation"); + create_error(&err,ox_serial,"ox_send_data : Mathcap violation",0); p = (pointer)err; } begin_critical(); @@ -532,13 +545,15 @@ void ox_send_data_102(int rank,pointer p) end_critical(); } -void ox_bcast_102(int root,Obj *rp) +void ox_bcast_102(int root) { Obj data; int r,mask,id,src,dst; - data = *rp; 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 ) { @@ -553,18 +568,19 @@ void ox_bcast_102(int root,Obj *rp) if ( dst >= nserver_102 ) dst -= nserver_102; ox_send_data_102(dst,data); } - *rp = data; + asir_push_one(data); } /* func : an arithmetic funcion func(vl,a,b,*c) */ -void ox_reduce_102(int root,void (*func)(),Obj data,Obj *rp) +void ox_reduce_102(int root,void (*func)()) { - Obj data0,t; + 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; @@ -580,10 +596,7 @@ void ox_reduce_102(int root,void (*func)(),Obj data,Ob (*func)(CO,data,data0,&t); data = t; } } - if ( !r ) - *rp = data; - else - *rp = 0; + asir_push_one(r?0:data); } void ox_send_cmd(int s,int id) @@ -862,7 +875,7 @@ int ox_check_cmo(int s, Obj obj) return check_by_mc(s,OX_DATA,CMO_ZZ); else return check_by_mc(s,OX_DATA,CMO_QQ); - case N_R: + case N_R: case N_B: return 1; default: return 0; @@ -875,6 +888,8 @@ int ox_check_cmo(int s, Obj obj) return 1; case O_QUOTE: /* XXX */ return 1; + case O_MAT: /* MAT is sent as a list */ + return 1; default: return 0; } @@ -923,7 +938,7 @@ void ox_flush_stream(int s) { if ( ox_batch ) return; -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) if ( _fileno(&iofp[s].out->fp) < 0 ) cflush(iofp[s].out); else @@ -937,7 +952,7 @@ void ox_flush_stream(int s) void ox_flush_stream_force(int s) { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) if ( _fileno(&iofp[s].out->fp) < 0 ) cflush(iofp[s].out); else @@ -958,7 +973,7 @@ void ox_flush_stream_102(int rank) void ox_flush_stream_force_102(int rank) { if ( iofp_102[rank].out ) -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) cflush(iofp_102[rank].out); #elif MPI cflush(iofp_102[rank].out);