void popup_msgs(void) { BUFFER *savebp = curbp; WINDOW *savewp = curwp; MARK savemk; register BUFFER *bp; WINDOW *wp; if ((bp = create_msgs()) == 0) return; savemk = DOT; if (!is_empty_buf(bp)) { if ((curwp == 0) || sgarbf || global_g_val(GMDPOPUP_MSGS) == -TRUE) { return; /* CAN'T popup yet */ } if (popupbuff(bp) == FALSE) { (void) zotbuf(bp); return; } if ((wp = bp2any_wp(bp)) != NULL) { make_local_w_val(wp, WMDNUMBER); set_w_val(wp, WMDNUMBER, FALSE); } set_rdonly(bp, non_filename(), MDVIEW); curbp = savebp; curwp = savewp; if (savewp) DOT = savemk; } }
/* * This is invoked as a wrapper for 'kbd_putc()'. It writes to the Messages * scratch buffer, and also to the message line. If the Messages buffer isn't * visible, it is automatically popped up when a new message line is begun. * Since it's a scratch buffer, popping it down destroys it. */ int msg_putc(int c) { BUFFER *savebp = curbp; WINDOW *savewp = curwp; MARK savemk; int saverow = ttrow; int savecol = ttcol; register BUFFER *bp; register WINDOW *wp; if ((bp = create_msgs()) == 0) return TRUE; savemk = DOT; beginDisplay(); /* * Modify the current-buffer state as unobtrusively as possible (i.e., * don't modify the buffer order, and don't make the buffer visible if * it isn't already!). To use the 'bputc()' logic, though, we've got * to have a window, even if it's not real. */ curbp = bp; if ((wp = bp2any_wp(bp)) == NULL) { static WINDOW dummy; wp = &dummy; wp->w_bufp = bp; } curwp = wp; DOT.l = lback(buf_head(bp)); DOT.o = llength(DOT.l); /* * Write into the [Messages]-buffer */ #if OPT_TRACE if (c == '\n') { static TBUFF *ss; int len = (DOT.o > 0) ? DOT.o : 1; if (tb_init(&ss, EOS) != 0 && tb_bappend(&ss, (DOT.o > 0) ? lvalue(DOT.l) : "?", (size_t) len) != 0 && tb_append(&ss, EOS) != 0) { TRACE(("msg:%s\n", visible_buff(tb_values(ss), (int) tb_length(ss) - 1, TRUE))); } } #endif if ((c != '\n') || (DOT.o > 0)) { bputc(c); b_clr_changed(bp); } /* Finally, restore the original current-buffer and write the character * to the message line. */ curbp = savebp; curwp = savewp; if (savewp) DOT = savemk; movecursor(saverow, savecol); if (c != '\n') { if (sgarbf) { mlsavec(c); } else { kbd_putc(c); } } endofDisplay(); return TRUE; }
int main (int argc, char** argv) { int i, nc; QMP_status_t status; int **smem, **rmem; QMP_msgmem_t *recvmem; QMP_msghandle_t *recvh; QMP_msgmem_t *sendmem; QMP_msghandle_t *sendh; struct perf_argv pargv; QMP_thread_level_t req, prv; /** * Simple point to point topology */ int dims[4] = {2,2,2,2}; int ndims = 1; //if(QMP_get_node_number()==0) //printf("starting init\n"); fflush(stdout); req = QMP_THREAD_SINGLE; status = QMP_init_msg_passing (&argc, &argv, req, &prv); if (status != QMP_SUCCESS) { fprintf (stderr, "QMP_init failed\n"); return -1; } if(QMP_get_node_number()==0) printf("finished init\n"); fflush(stdout); if (parse_options (argc, argv, &pargv) == -1) { if(QMP_get_node_number()==0) usage (argv[0]); exit (1); } { int maxdims = 4; int k=0; int nodes = QMP_get_number_of_nodes(); ndims = 0; while( (nodes&1) == 0 ) { if(ndims<maxdims) ndims++; else { dims[k] *= 2; k++; if(k>=maxdims) k = 0; } nodes /= 2; } if(nodes != 1) { QMP_error("invalid number of nodes %i", QMP_get_number_of_nodes()); QMP_error(" must power of 2"); QMP_abort(1); } pargv.ndims = ndims; } status = QMP_declare_logical_topology (dims, ndims); if (status != QMP_SUCCESS) { fprintf (stderr, "Cannot declare logical grid\n"); return -1; } /* do a broadcast of parameter */ if (QMP_broadcast (&pargv, sizeof (pargv)) != QMP_SUCCESS) { QMP_printf ("Broadcast parameter failed\n"); exit (1); } { int k=1; const int *lc = QMP_get_logical_coordinates(); for(i=0; i<ndims; i++) k += lc[i]; pargv.sender = k&1; } QMP_printf("%s options: num_channels[%d] verify[%d] option[%d] datasize[%d] numloops[%d] sender[%d] strided_send[%i] strided_recv[%i] strided_array_send[%i] ", argv[0], pargv.num_channels, pargv.verify, pargv.option, pargv.size, pargv.loops, pargv.sender, strided_send, strided_recv, strided_array_send); fflush(stdout); /** * Create memory */ nc = pargv.num_channels; smem = (int **)malloc(nc*sizeof (int *)); rmem = (int **)malloc(nc*sizeof (int *)); sendmem = (QMP_msgmem_t *)malloc(ndims*nc*sizeof (QMP_msgmem_t)); recvmem = (QMP_msgmem_t *)malloc(ndims*nc*sizeof (QMP_msgmem_t)); sendh = (QMP_msghandle_t *)malloc(nc*sizeof (QMP_msghandle_t)); recvh = (QMP_msghandle_t *)malloc(nc*sizeof (QMP_msghandle_t)); QMP_barrier(); if(QMP_get_node_number()==0) printf("\n"); fflush(stdout); if(pargv.option & TEST_SIMUL) { int opts = pargv.option; pargv.option = TEST_SIMUL; if(QMP_get_node_number()==0) QMP_printf("starting simultaneous sends"); fflush(stdout); for(i=pargv.minsize; i<=pargv.maxsize; i*=pargv.facsize) { pargv.size = i; create_msgs(smem, rmem, sendmem, recvmem, sendh, recvh, ndims, nc, i, &pargv); test_simultaneous_send (smem, rmem, sendh, recvh, &pargv); check_mem(rmem, ndims, nc, i); free_msgs(smem, rmem, sendmem, recvmem, sendh, recvh, ndims, nc); } if(QMP_get_node_number()==0) QMP_printf("finished simultaneous sends\n"); fflush(stdout); pargv.option = opts; } if(pargv.option & TEST_PINGPONG) { int opts = pargv.option; pargv.option = TEST_PINGPONG; if(QMP_get_node_number()==0) QMP_printf("starting ping pong sends"); fflush(stdout); for(i=pargv.minsize; i<=pargv.maxsize; i*=pargv.facsize) { pargv.size = i; create_msgs(smem, rmem, sendmem, recvmem, sendh, recvh, ndims, nc, i, &pargv); if(pargv.verify) test_pingpong_verify(smem, rmem, sendh, recvh, &pargv); else test_pingpong(smem, rmem, sendh, recvh, &pargv); check_mem(rmem, ndims, nc, i); free_msgs(smem, rmem, sendmem, recvmem, sendh, recvh, ndims, nc); } if(QMP_get_node_number()==0) QMP_printf("finished ping pong sends\n"); fflush(stdout); pargv.option = opts; } if(pargv.option & TEST_ONEWAY) { int opts = pargv.option; pargv.option = TEST_ONEWAY; if(QMP_get_node_number()==0) QMP_printf("starting one way sends"); fflush(stdout); for(i=pargv.minsize; i<=pargv.maxsize; i*=pargv.facsize) { pargv.size = i; create_msgs(smem, rmem, sendmem, recvmem, sendh, recvh, ndims, nc, i, &pargv); test_oneway (smem, rmem, sendh, recvh, &pargv); if(!pargv.sender) check_mem(rmem, ndims, nc, i); free_msgs(smem, rmem, sendmem, recvmem, sendh, recvh, ndims, nc); } if(QMP_get_node_number()==0) QMP_printf("finished one way sends"); fflush(stdout); pargv.option = opts; } /** * Free memory */ free (smem); free (rmem); free (sendh); free (recvh); free (sendmem); free (recvmem); QMP_finalize_msg_passing (); return 0; }