void end_as_line_no(Node list_node, struct prsstack *next_token) /*;end_as_line_no*/ { /* add an as_line_no node to end of statement list this is the line * number of the token following the sequence of statements */ Node line_node; if (N_LIST(list_node) != (Tuple)0) { line_node = node_new (as_line_no); N_ID(line_node) = next_token->ptr.token->span.line ; set_span(line_node, make_span(N_ID(line_node), next_token->ptr.token->span.col)); N_LIST(list_node) = tup_with(N_LIST(list_node), (char *)line_node); } }
//Compute grid data and the plane from box and view. void MGConstructionPlane::set_grid_data( const MGBox& box, int view_num //Standard view number: //1: 3D perspective view, 2:(x,y) 2D view, 3:(y,z) 2D view, 4:(z,x) 2D view //0: non standard view. ){ double span; size_t lnum; MGPosition mid; size_t sdid;//maxmum area coordinate pair will be output. //0:(x,y), 1:(y,z), 2:(z,x) MGcplane_parameter(box,span,lnum,sdid,mid); if(view_num>=2 && view_num<=4) sdid=size_t(view_num-2); set_span(span); set_num(lnum); MGVector uderi(0.,0.,0.),vderi(0.,0.,0.); size_t sdid2=(sdid+2)%3, sdid1=(sdid+1)%3; uderi(sdid)=1.; vderi(sdid1)=1.; plane()=MGPlane(uderi,vderi,mid); }
/* * route_split_hostlist_treewidth - logic to split an input hostlist into * a set of hostlists to forward to. * * This is the default behavior. It is implemented here as there are cases * where the topology version also needs to split the message list based * on TreeWidth. * * IN: hl - hostlist_t - list of every node to send message to * will be empty on return which is same behavior * as similar code replaced in forward.c * OUT: sp_hl - hostlist_t** - the array of hostlists that will be malloced * OUT: count - int* - the count of created hostlists * RET: SLURM_SUCCESS - int * * Note: created hostlist will have to be freed independently using * hostlist_destroy by the caller. * Note: the hostlist_t array will have to be xfree. */ extern int route_split_hostlist_treewidth(hostlist_t hl, hostlist_t** sp_hl, int* count) { int host_count; int *span = NULL; char *name = NULL; char *buf; int nhl = 0; int j; host_count = hostlist_count(hl); span = set_span(host_count, tree_width); *sp_hl = (hostlist_t*) xmalloc(tree_width * sizeof(hostlist_t)); while ((name = hostlist_shift(hl))) { (*sp_hl)[nhl] = hostlist_create(name); free(name); for (j = 0; j < span[nhl]; j++) { name = hostlist_shift(hl); if (!name) { break; } hostlist_push_host((*sp_hl)[nhl], name); free(name); } if (debug_flags & DEBUG_FLAG_ROUTE) { buf = hostlist_ranged_string_xmalloc((*sp_hl)[nhl]); debug("ROUTE: ... sublist[%d] %s", nhl, buf); xfree(buf); } nhl++; } xfree(span); *count = nhl; return SLURM_SUCCESS; }
void ins_as_line_no(Node node) /*;ins_as_line_no*/ { /* insert as_line_no nodes before each item in declarative/stmt list */ Tuple new_list = tup_new(0); Node tmp_node; Fortup ft1; Node line_node; Span line_node_span; FORTUP(tmp_node = (Node), N_LIST(node), ft1); line_node = node_new (as_line_no); line_node_span = get_left_span_p(tmp_node); N_ID(line_node) = line_node_span->line; set_span(line_node,line_node_span); /* Insert a new node with the as_line_no between dec_list and its predecessor */ new_list = tup_with(new_list, (char *)line_node); new_list = tup_with(new_list, (char *)tmp_node); ENDFORTUP(ft1); N_LIST(node) = new_list; }
color_render_ESWC_dialog::color_render_ESWC_dialog(V3DPluginCallback2 * cb, V3dR_MainWindow* inwin, int nid) { v3dwin=inwin; callback=cb; //load neuron tree nt=(NeuronTree*)&(callback->getHandleNeuronTrees_Any3DViewer(v3dwin)->at(nid)); feaNum=nt->listNeuron.at(0).fea_val.size(); if(feaNum<=0.1){ v3d_msg("Cannot identify feature value for the selected neuron"); return; } //back up type bk_type.clear(); for(int i=0; i<nt->listNeuron.size(); i++){ bk_type.push_back(nt->listNeuron.at(i).type); } //create this->setWindowTitle(nt->file); cb_feature = new QComboBox(); for(int i=0; i<feaNum; i++) cb_feature->addItem(QString::number(i+1)); cb_colormap= new QComboBox(); cb_colormap->addItem(QString("heatmap")); cb_colormap->addItem(QString("rainbow")); spin_min = new QDoubleSpinBox(); spin_max = new QDoubleSpinBox(); spin_black = new QDoubleSpinBox(); spin_white = new QDoubleSpinBox(); spin_meg = new QDoubleSpinBox(); check_black = new QCheckBox("black threshold (<=)"); check_white = new QCheckBox("white threshold (<=)"); check_meg = new QCheckBox("magenta threshold (>=)"); btn_update = new QPushButton("update"); btn_quit = new QPushButton("quit"); btn_reset = new QPushButton("reset"); connect(check_black, SIGNAL(clicked()),this,SLOT(set_black())); connect(check_white, SIGNAL(clicked()),this,SLOT(set_white())); connect(check_meg, SIGNAL(clicked()),this,SLOT(set_magenta())); connect(btn_update, SIGNAL(clicked()),this,SLOT(update())); connect(btn_quit, SIGNAL(clicked()),this,SLOT(reject())); connect(btn_reset, SIGNAL(clicked()),this,SLOT(reset())); connect(cb_feature, SIGNAL(currentIndexChanged(int)),this,SLOT(set_span())); connect(cb_colormap, SIGNAL(currentIndexChanged(int)),this,SLOT(set_colormap())); //layout QGridLayout * gridLayout = new QGridLayout(); QLabel* label_feature = new QLabel("feature id:"); gridLayout->addWidget(label_feature,1,0,1,2); gridLayout->addWidget(cb_feature,1,2,1,1); QLabel* label_colormap= new QLabel("colormap:"); gridLayout->addWidget(label_colormap,2,0,1,2); gridLayout->addWidget(cb_colormap,2,2,1,1); QLabel* label_min = new QLabel("color bar low:"); gridLayout->addWidget(label_min,3,0,1,2); gridLayout->addWidget(spin_min,3,2,1,1); QLabel* label_max = new QLabel("color bar high:"); gridLayout->addWidget(label_max,4,0,1,2); gridLayout->addWidget(spin_max,4,2,1,1); QFrame *line_2 = new QFrame(); line_2->setFrameShape(QFrame::HLine); line_2->setFrameShadow(QFrame::Sunken); gridLayout->addWidget(line_2,5,0,1,3); QLabel* label_color = new QLabel("special color"); QLabel* label_val = new QLabel("value"); gridLayout->addWidget(label_color,6,0,1,2); gridLayout->addWidget(label_val,6,2,1,1); gridLayout->addWidget(check_black,7,0,1,2); gridLayout->addWidget(spin_black,7,2,1,1); gridLayout->addWidget(check_white,8,0,1,2); gridLayout->addWidget(spin_white,8,2,1,1); gridLayout->addWidget(check_meg,9,0,1,2); gridLayout->addWidget(spin_meg,9,2,1,1); QFrame *line_3 = new QFrame(); line_3->setFrameShape(QFrame::HLine); line_3->setFrameShadow(QFrame::Sunken); gridLayout->addWidget(line_3,13,0,1,3); gridLayout->addWidget(btn_update,14,2,1,1); gridLayout->addWidget(btn_reset,15,2,1,1); gridLayout->addWidget(btn_quit,16,2,1,1); setLayout(gridLayout); set_black(); set_white(); set_magenta(); set_span(); set_colormap(); }
static agent_info_t *_make_agent_info(agent_arg_t *agent_arg_ptr) { int i = 0, j = 0; agent_info_t *agent_info_ptr = NULL; thd_t *thread_ptr = NULL; int *span = NULL; int thr_count = 0; hostlist_t hl = NULL; char *name = NULL; agent_info_ptr = xmalloc(sizeof(agent_info_t)); slurm_mutex_init(&agent_info_ptr->thread_mutex); if (pthread_cond_init(&agent_info_ptr->thread_cond, NULL)) fatal("pthread_cond_init error %m"); agent_info_ptr->thread_count = agent_arg_ptr->node_count; agent_info_ptr->retry = agent_arg_ptr->retry; agent_info_ptr->threads_active = 0; thread_ptr = xmalloc(agent_info_ptr->thread_count * sizeof(thd_t)); memset(thread_ptr, 0, (agent_info_ptr->thread_count * sizeof(thd_t))); agent_info_ptr->thread_struct = thread_ptr; agent_info_ptr->msg_type = agent_arg_ptr->msg_type; agent_info_ptr->msg_args_pptr = &agent_arg_ptr->msg_args; if ((agent_arg_ptr->msg_type != REQUEST_JOB_NOTIFY) && (agent_arg_ptr->msg_type != REQUEST_SHUTDOWN) && (agent_arg_ptr->msg_type != REQUEST_RECONFIGURE) && (agent_arg_ptr->msg_type != SRUN_EXEC) && (agent_arg_ptr->msg_type != SRUN_TIMEOUT) && (agent_arg_ptr->msg_type != SRUN_NODE_FAIL) && (agent_arg_ptr->msg_type != SRUN_REQUEST_SUSPEND) && (agent_arg_ptr->msg_type != SRUN_USER_MSG) && (agent_arg_ptr->msg_type != SRUN_STEP_MISSING) && (agent_arg_ptr->msg_type != SRUN_JOB_COMPLETE)) { #ifdef HAVE_FRONT_END span = set_span(agent_arg_ptr->node_count, agent_arg_ptr->node_count); #else /* Sending message to a possibly large number of slurmd. * Push all message forwarding to slurmd in order to * offload as much work from slurmctld as possible. */ span = set_span(agent_arg_ptr->node_count, 1); #endif agent_info_ptr->get_reply = true; } else { /* Message is going to one node (for srun) or we want * it to get processed ASAP (SHUTDOWN or RECONFIGURE). * Send the message directly to each node. */ span = set_span(agent_arg_ptr->node_count, agent_arg_ptr->node_count); } i = 0; while(i < agent_info_ptr->thread_count) { thread_ptr[thr_count].state = DSH_NEW; thread_ptr[thr_count].addr = agent_arg_ptr->addr; name = hostlist_shift(agent_arg_ptr->hostlist); if(!name) { debug3("no more nodes to send to"); break; } hl = hostlist_create(name); if(thread_ptr[thr_count].addr && span[thr_count]) { debug("warning: you will only be sending this to %s", name); span[thr_count] = 0; } free(name); i++; for (j = 0; j < span[thr_count]; j++) { name = hostlist_shift(agent_arg_ptr->hostlist); if (!name) break; hostlist_push(hl, name); free(name); i++; } hostlist_uniq(hl); thread_ptr[thr_count].nodelist = hostlist_ranged_string_xmalloc(hl); hostlist_destroy(hl); #if 0 info("sending msg_type %u to nodes %s", agent_arg_ptr->msg_type, thread_ptr[thr_count].nodelist); #endif thr_count++; } xfree(span); agent_info_ptr->thread_count = thr_count; return agent_info_ptr; }
/* * start_msg_tree - logic to begin the forward tree and * accumulate the return codes from processes getting the * the forwarded message * * IN: hl - hostlist_t - list of every node to send message to * IN: msg - slurm_msg_t - message to send. * IN: timeout - int - how long to wait in milliseconds. * RET List - List containing the responses of the childern * (if any) we forwarded the message to. List * containing type (ret_data_info_t). */ extern List start_msg_tree(hostlist_t hl, slurm_msg_t *msg, int timeout) { int *span = NULL; fwd_tree_t *fwd_tree = NULL; pthread_mutex_t tree_mutex; pthread_cond_t notify; int j = 0, count = 0; List ret_list = NULL; char *name = NULL; int thr_count = 0; int host_count = 0; xassert(hl); xassert(msg); hostlist_uniq(hl); host_count = hostlist_count(hl); span = set_span(host_count, 0); slurm_mutex_init(&tree_mutex); pthread_cond_init(¬ify, NULL); ret_list = list_create(destroy_data_info); while ((name = hostlist_shift(hl))) { pthread_attr_t attr_agent; pthread_t thread_agent; int retries = 0; slurm_attr_init(&attr_agent); if (pthread_attr_setdetachstate (&attr_agent, PTHREAD_CREATE_DETACHED)) error("pthread_attr_setdetachstate error %m"); fwd_tree = xmalloc(sizeof(fwd_tree_t)); fwd_tree->orig_msg = msg; fwd_tree->ret_list = ret_list; fwd_tree->timeout = timeout; fwd_tree->notify = ¬ify; fwd_tree->p_thr_count = &thr_count; fwd_tree->tree_mutex = &tree_mutex; if (fwd_tree->timeout <= 0) { /* convert secs to msec */ fwd_tree->timeout = slurm_get_msg_timeout() * 1000; } fwd_tree->tree_hl = hostlist_create(name); free(name); for (j = 0; j < span[thr_count]; j++) { name = hostlist_shift(hl); if (!name) break; hostlist_push(fwd_tree->tree_hl, name); free(name); } /* * Lock and increase thread counter, we need that to protect * the start_msg_tree waiting loop that was originally designed * around a "while ((count < host_count))" loop. In case where a * fwd thread was not able to get all the return codes from * children, the waiting loop was deadlocked. */ slurm_mutex_lock(&tree_mutex); thr_count++; slurm_mutex_unlock(&tree_mutex); while (pthread_create(&thread_agent, &attr_agent, _fwd_tree_thread, (void *)fwd_tree)) { error("pthread_create error %m"); if (++retries > MAX_RETRIES) fatal("Can't create pthread"); sleep(1); /* sleep and try again */ } slurm_attr_destroy(&attr_agent); } xfree(span); slurm_mutex_lock(&tree_mutex); count = list_count(ret_list); debug2("Tree head got back %d looking for %d", count, host_count); while (thr_count > 0) { pthread_cond_wait(¬ify, &tree_mutex); count = list_count(ret_list); debug2("Tree head got back %d", count); } xassert(count >= host_count); /* Tree head did not get all responses, * but no more active fwd threads!*/ slurm_mutex_unlock(&tree_mutex); slurm_mutex_destroy(&tree_mutex); pthread_cond_destroy(¬ify); return ret_list; }
/* * forward_msg - logic to forward a message which has been received and * accumulate the return codes from processes getting the * the forwarded message * * IN: forward_struct - forward_struct_t * - holds information about message * that needs to be forwarded to * childern processes * IN: header - header_t - header from message that came in * needing to be forwarded. * RET: SLURM_SUCCESS - int */ extern int forward_msg(forward_struct_t *forward_struct, header_t *header) { int j = 0; int retries = 0; forward_msg_t *forward_msg = NULL; int thr_count = 0; int *span = set_span(header->forward.cnt, 0); hostlist_t hl = NULL; hostlist_t forward_hl = NULL; char *name = NULL; if (!forward_struct->ret_list) { error("didn't get a ret_list from forward_struct"); xfree(span); return SLURM_ERROR; } hl = hostlist_create(header->forward.nodelist); hostlist_uniq(hl); while ((name = hostlist_shift(hl))) { pthread_attr_t attr_agent; pthread_t thread_agent; char *buf = NULL; slurm_attr_init(&attr_agent); if (pthread_attr_setdetachstate (&attr_agent, PTHREAD_CREATE_DETACHED)) error("pthread_attr_setdetachstate error %m"); forward_msg = &forward_struct->forward_msg[thr_count]; forward_msg->ret_list = forward_struct->ret_list; forward_msg->timeout = forward_struct->timeout; if (forward_msg->timeout <= 0) { /* convert secs to msec */ forward_msg->timeout = slurm_get_msg_timeout() * 1000; } forward_msg->notify = &forward_struct->notify; forward_msg->forward_mutex = &forward_struct->forward_mutex; forward_msg->buf_len = forward_struct->buf_len; forward_msg->buf = forward_struct->buf; memcpy(&forward_msg->header.orig_addr, &header->orig_addr, sizeof(slurm_addr_t)); forward_msg->header.version = header->version; forward_msg->header.flags = header->flags; forward_msg->header.msg_type = header->msg_type; forward_msg->header.body_length = header->body_length; forward_msg->header.ret_list = NULL; forward_msg->header.ret_cnt = 0; forward_hl = hostlist_create(name); free(name); for(j = 0; j < span[thr_count]; j++) { name = hostlist_shift(hl); if (!name) break; hostlist_push(forward_hl, name); free(name); } buf = hostlist_ranged_string_xmalloc(forward_hl); hostlist_destroy(forward_hl); forward_init(&forward_msg->header.forward, NULL); forward_msg->header.forward.nodelist = buf; while (pthread_create(&thread_agent, &attr_agent, _forward_thread, (void *)forward_msg)) { error("pthread_create error %m"); if (++retries > MAX_RETRIES) fatal("Can't create pthread"); sleep(1); /* sleep and try again */ } slurm_attr_destroy(&attr_agent); thr_count++; } hostlist_destroy(hl); xfree(span); return SLURM_SUCCESS; }
/* * start_msg_tree - logic to begin the forward tree and * accumulate the return codes from processes getting the * the forwarded message * * IN: hl - hostlist_t - list of every node to send message to * IN: msg - slurm_msg_t - message to send. * IN: timeout - int - how long to wait in milliseconds. * RET List - List containing the responses of the childern * (if any) we forwarded the message to. List * containing type (ret_data_info_t). */ extern List start_msg_tree(hostlist_t hl, slurm_msg_t *msg, int timeout) { int *span = NULL; fwd_tree_t *fwd_tree = NULL; pthread_mutex_t tree_mutex; pthread_cond_t notify; int j = 0, count = 0; List ret_list = NULL; char *name = NULL; int thr_count = 0; int host_count = 0; xassert(hl); xassert(msg); hostlist_uniq(hl); host_count = hostlist_count(hl); span = set_span(host_count, 0); slurm_mutex_init(&tree_mutex); pthread_cond_init(¬ify, NULL); ret_list = list_create(destroy_data_info); while ((name = hostlist_shift(hl))) { pthread_attr_t attr_agent; pthread_t thread_agent; int retries = 0; slurm_attr_init(&attr_agent); if (pthread_attr_setdetachstate (&attr_agent, PTHREAD_CREATE_DETACHED)) error("pthread_attr_setdetachstate error %m"); fwd_tree = xmalloc(sizeof(fwd_tree_t)); fwd_tree->orig_msg = msg; fwd_tree->ret_list = ret_list; fwd_tree->timeout = timeout; fwd_tree->notify = ¬ify; fwd_tree->tree_mutex = &tree_mutex; if(fwd_tree->timeout <= 0) { /* convert secs to msec */ fwd_tree->timeout = slurm_get_msg_timeout() * 1000; } fwd_tree->tree_hl = hostlist_create(name); free(name); for (j = 0; j < span[thr_count]; j++) { name = hostlist_shift(hl); if (!name) break; hostlist_push(fwd_tree->tree_hl, name); free(name); } while (pthread_create(&thread_agent, &attr_agent, _fwd_tree_thread, (void *)fwd_tree)) { error("pthread_create error %m"); if (++retries > MAX_RETRIES) fatal("Can't create pthread"); sleep(1); /* sleep and try again */ } slurm_attr_destroy(&attr_agent); thr_count++; } xfree(span); slurm_mutex_lock(&tree_mutex); count = list_count(ret_list); debug2("Tree head got back %d looking for %d", count, host_count); while ((count < host_count)) { pthread_cond_wait(¬ify, &tree_mutex); count = list_count(ret_list); debug2("Tree head got back %d", count); } debug2("Tree head got them all"); slurm_mutex_unlock(&tree_mutex); slurm_mutex_destroy(&tree_mutex); pthread_cond_destroy(¬ify); return ret_list; }