sl_def(t_main, void) { sl_decl_fptr(foo2, void, sl_glparm(int, x)) = &foo; sl_create(,,,,,,, *foo1, sl_glarg(int, , 0)); sl_sync(); sl_create(,,,,,,, *foo2, sl_glarg(int, , 0)); sl_sync(); }
sl_enddef /* Further partitions a list of intervals * level: level of the current list to be partitioned */ sl_def(partition_list_of_intervals, void, sl_glparm(INT*, data), sl_glparm(SIZE, len), sl_glparm(INT*, scratch), sl_shparm(INT, level), sl_shparm(INT, done) ) { sl_index(i); INT done = sl_getp(done); if (!done) { INT* d = sl_getp(data); SIZE l = sl_getp(len); INT level = sl_getp(level); INT* scratch = sl_getp(scratch); //printf("PARTIITON LIST: level = %d\n", level); num_intervals[(level+1)%2] = 0; // partition the intervals sl_create(,,0,num_intervals[level%2],,,,partition_interval, sl_glarg(INT*, gdata, d), sl_glarg(INT*, gres, scratch), sl_glarg(SIZE, level, level), sl_sharg(int, done, 1)); sl_sync(); // copy partitoned values back to d sl_create(,,0,l,,,, copy_array, sl_glarg(INT*, gdestination, d), sl_glarg(INT*, gsource, scratch)); sl_sync(); int j = 0; if (num_intervals[(level+1)%2] == 0) { // no intervals for the next level => we're done sl_setp(level, 0); // value doesn't matter, just unblock sibling sl_setp(done, 1); } else { // trigger the next sibling to start sl_setp(level, level+1); sl_setp(done, 0); } } else { // if (!done)
sl_enddef // 2009-04-02: FIXME: we acknowledge that muTC-ptl // does not support this construct fully yet; but // we want slc's testsuite to properly succeed. So // we mark the test to ignore the output on muTC-ptl: // XIGNORE: ptl*:D sl_def(t_main, void) { int busy; sl_create(,,,,,,, foo, sl_sharg(int, a)); // FIXME: for ptl here we should find a way to // force a context switch, otherwise the problem // is not demonstrated. In the previous version // of this test, a call was done to the C library's // putc() function, but we can't do this in SL // because putc is a thread function and we cannot // nest creates. for (busy = 0; busy < 10000; ++busy) nop(); sl_seta(a, 42); sl_sync(); output_int(sl_geta(a), 1); output_char('\n', 1); }
sl_enddef #ifdef REDUCTIONS // method to perform a graph reduction of the above dependent kernel over CORES sl_def(reductionk3, void, sl_shfparm(double, Q), sl_glparm(const double*restrict, Z), sl_glparm(const double*restrict, X), sl_glparm(long, iternum)) { sl_index(redindex); long lower = sl_getp(iternum) * redindex; long upper = lower + sl_getp(iternum); sl_create(,PLACE_LOCAL, lower, upper, 1,,, innerk3, sl_shfarg(double, Qr, 0.0), sl_glarg(const double*, , sl_getp(Z)), sl_glarg(const double*, , sl_getp(X))); sl_sync(); //now accumilate the results sl_setp(Q, sl_geta(Qr) + sl_getp(Q) ); }
sl_def(foo,void,sl_glparm(int, x)) { if (sl_getp(x) > 0) { sl_create(,,,,,,,foo,sl_glarg(int,,sl_getp(x)-1)); sl_sync(); } else {
sl_enddef sl_def(kernel21, void, sl_glparm(size_t, ncores), sl_glparm(size_t, n) , sl_glparm(const double*restrict, CX) , sl_glparm(size_t, CX_dim0) , sl_glparm(size_t, CX_dim1) , sl_glparm(double*restrict, PX) , sl_glparm(size_t, PX_dim0) , sl_glparm(size_t, PX_dim1) , sl_glparm(const double*restrict, VY) , sl_glparm(size_t, VY_dim0) , sl_glparm(size_t, VY_dim1) ) { assert(sl_getp(PX_dim1) == 25); assert(sl_getp(CX_dim1) == 25); assert(sl_getp(VY_dim0) == 25); assert(sl_getp(VY_dim1) == 25); //create the family of the appropriate size //specified in the 'inner' array sl_create(,, 0, 25*sl_getp(n),1, 0,, cell, sl_glarg(size_t, , sl_getp(n)), sl_glarg(const double*, , sl_getp(VY)), sl_glarg(const double*, , sl_getp(CX)), sl_glarg(double*, , sl_getp(PX))); sl_sync(); }
/* Registers the SL main function */ sl_def(t_main, void) { init(); sl_create(,worker_place_id,,,0,block_size,,gol,sl_sharg(int,breaked,0)); sl_sync(); }
sl_enddef /** GOL **/ sl_def(gol,void,sl_shparm(int,breaked)) { sl_index(index); int flag = sl_getp(breaked); if(flag==0) { //info_print("GOL Thread %d :Processing %d blocks\n", index, b_queue->elements); //printf("GOL Thread %d :Processing %d blocks\n", index, b_queue->elements); //info_print("%d\n",iter); if( index + 1 == cycle) flag = 1; debug_print("Creating Worker family...\n"); sl_create(,,,,0,block_size,,run,sl_glarg(int,iteration,index),sl_sharg(int,sta,0)); debug_print("Waiting for sync...\n"); sl_sync(); debug_print("Workers finished, processing request queue...\n"); sl_create(,,,,0,block_size,,process_requests,sl_sharg(int,stat,0)); debug_print("Waiting for sync...\n"); sl_sync(); debug_print("Request queue processing finished, traversing...\n"); b_queue->elements = 0; sl_create(,,,,0,block_size,,traverse,sl_sharg(int,state,1),sl_sharg(struct hashtable_itr*,itr,hashtable_iterator(table))); debug_print("Waiting for sync...\n"); sl_sync(); sl_setp(breaked,flag); if(flag == 1) sl_break; } else {
sl_enddef sl_def(sha_main_outer, void, sl_glparm(const uint32_t*restrict, input), sl_shparm(unsigned long, h0), sl_shparm(unsigned long, h1), sl_shparm(unsigned long, h2), sl_shparm(unsigned long, h3), sl_shparm(unsigned long, h4)) { sl_index(offset_base); int i; const uint32_t*restrict input = sl_getp(input) + offset_base; /* word extension: not easily made concurrent! */ uint32_t w[80]; sl_create(,PLACE_LOCAL,,16,,,, buf_copy, sl_glarg(const uint32_t*restrict, src, input), sl_glarg(uint32_t*restrict, dst, w)); sl_sync(); // for (i = 0; i < 16; ++i) w[i] = input[i]; for (i = 16; i < 80; ++i) { uint32_t x = w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]; w[i] = ROL32(x, 1); } sl_create(,,,80,,,, sha_main_inner, sl_glarg(const uint32_t*restrict, wg, w), sl_sharg(unsigned long, a), sl_sharg(unsigned long, b), sl_sharg(unsigned long, c), sl_sharg(unsigned long, d), sl_sharg(unsigned long, e)); sl_seta(a, sl_getp(h0)); sl_seta(b, sl_getp(h1)); sl_seta(c, sl_getp(h2)); sl_seta(d, sl_getp(h3)); sl_seta(e, sl_getp(h4)); sl_sync(); sl_setp(h0, sl_getp(h0) + sl_geta(a)); sl_setp(h1, sl_getp(h1) + sl_geta(b)); sl_setp(h2, sl_getp(h2) + sl_geta(c)); sl_setp(h3, sl_getp(h3) + sl_geta(d)); sl_setp(h4, sl_getp(h4) + sl_geta(e)); }
sl_def(foo, void) { sl_break; } sl_enddef sl_def(t_main, void) { int r; sl_create(,,,,,, void, foo); sl_sync(r); if (r == SVP_EXIT_BREAK) nop(); }
// done: used by a thread to signal it's right sibling when it finished sl_def(partition_interval, void, sl_glparm(INT*, data), sl_glparm(INT*, result), sl_glparm(SIZE, level), sl_shparm(int, done) ) { sl_index(i); INT* data = sl_getp(data); INT* result = sl_getp(result); SIZE level = sl_getp(level); int l = intervals[level%2][i].l; int r = intervals[level%2][i].r; if (l == r) { // this interval is sorted (1 element), so don't copy it to the // next level result[l] = data[l]; sl_setp(done, sl_getp(done)); } else { sl_create(,,1,r - l + 1,,,, do_partition_interval, sl_glarg(INT*, gdata, data + l), sl_glarg(INT*, gres, result + l), sl_sharg(SIZE, lower, 0), sl_sharg(SIZE, greater, r - l)); sl_sync(); SIZE la = sl_geta(lower); la = la + l; result[la] = data[l]; // put the pivot in the right place // copy the 2 new intervals to next level // but after the left sibling has done doing the same int left_done = sl_getp(done); workaround += left_done; // use the value, so the read doesn't get // optimized away. See comment for workaround. if (l < la) { // don't copy an interval of len=1 intervals[(level+1)%2][num_intervals[(level+1) % 2]].l = l; intervals[(level+1)%2][num_intervals[(level+1) % 2]].r = la; num_intervals[(level+1) % 2]++; } if (la + 1 < r) { // don't copy an interval of len=1 intervals[(level+1)%2][num_intervals[(level+1) % 2]].l = la + 1; intervals[(level+1)%2][num_intervals[(level+1) % 2]].r = r; num_intervals[(level+1) % 2]++; } //signal to the right sibling that I'm done sl_setp(done, 0); } }
int test(void) { int r; sl_create(,, -10,200,10, 0, , icount, sl_sharg(unsigned, count, 0), sl_glarg(unsigned, max, 20)); sl_sync(r); if (r != SVP_EXIT_BREAK) return 1; // should see break here if (sl_geta(count) != 20) return 1; sl_create(,,, sl_geta(count),,,, iprint, sl_sharg(unsigned, c, 0), sl_glarg(unsigned, refc, sl_geta(count))); sl_sync(); return 0; }
sl_def(t_main, void) { assert(slr_len(N) >= 1); unsigned N = slr_get(N)[0] + 1; INT fibonums[N]; // first, compute the numbers. fibonums[0] = fibonums[1] = 1; sl_create(,,2,N,,,, fibo_compute, sl_sharg(INT, prev, 1), sl_sharg(INT, prev2, 1), sl_glarg(INT*, fibo, fibonums)); sl_sync(); // then, print them. sl_create(,,2,N,,,, fibo_print, sl_sharg(INT, guard, 0), sl_glarg(INT*, t, fibonums)); sl_sync(); }
sl_enddef sl_def (t_main, void) { int N=51; if (N < 0) printf("%d\n", -1); else if (N > 51) printf("%d\n", -2); else { sl_create(,,1,N+1,2,,,thread,s1_sharg(int, _s, 1)); sl_sync(); printf("%d\n", s1_geta(_s)); } }
sl_enddef sl_def(outerk2, void, sl_glparm(double*restrict, X), sl_glparm(const double*restrict, V), sl_shparm(unsigned long, ii), sl_shparm(unsigned long, ipntp)) { sl_index(m); unsigned long ipnt, ii; unsigned long ipntp = (ii = sl_getp(ii)) + (ipnt = sl_getp(ipntp)); sl_setp(ii, ii/2); sl_create(,,1,ii,2,,, innerk2, sl_glarg(double*restrict, , sl_getp(X)), sl_glarg(const double*restrict, , sl_getp(V)), sl_glarg(unsigned long, , ipnt), sl_glarg(unsigned long, , ipntp)); sl_sync(); sl_setp(ipntp, ipntp); }
sl_enddef #include <math.h> sl_def(kernel2, void, sl_glparm(size_t, ncores), sl_glparm(size_t, n), sl_glparm(const double*restrict, V), sl_glparm(size_t, V_dim), sl_glparm(double*restrict, X), sl_glparm(size_t, X_dim)) { // output_int(sl_getp(n), 2); output_char('\n', 2); unsigned long upper = log2(sl_getp(n)); sl_create(,,upper,-1,-1,2,, outerk2, sl_glarg(double*restrict, , sl_getp(X)), sl_glarg(const double*restrict, , sl_getp(V)), sl_sharg(unsigned long, ii, sl_getp(n)), sl_sharg(unsigned long, ipntp, 0)); sl_sync(); }
sl_enddef // XIGNORE: mts*:D // SLT_RUN: -f TEST.d1 // SLT_RUN: -f TEST.d2 int main(int argc, char **argv) { int j; double x = .42; int n = 42; assert(fibre_tag(0) == 2 && fibre_rank(0) == 0); assert(fibre_tag(1) == 0 && fibre_rank(1) == 0); x = *(double*)fibre_data(0); n = *(long*)fibre_data(1); for(j = 0; j < MAX_TESTS; ++j) { values[j].desc = 0; values[j].f = values[j].d = x; values[j].i = values[j].l = values[j].ll = n; } sl_create(,,,,,,, do_test); sl_sync(); double_t xd = x; float_t xf = x; output_string("dot forty two, d: ", 1); output_float(xd, 1, 4); output_char('\n', 1); output_string("dot forty two, f: ", 1); output_float(xf, 1, 4); output_char('\n', 1); output_string("HUGE_VAL: ", 1); output_float(HUGE_VAL, 1, 4); output_char('\n', 1); output_string("HUGE_VALF: ", 1); output_float(HUGE_VALF, 1, 4); output_char('\n', 1); output_string("INFINITY: ", 1); output_float(INFINITY, 1, 4); output_char('\n', 1); output_string("NAN: ", 1); output_float(NAN, 1, 4); output_char('\n', 1); output_string("FP_ILOGB0 // ilogb(0): ", 1); output_int(FP_ILOGB0 == ilogb(0), 1); output_char('\n', 1); output_string("FP_ILOGBNAN // ilogb(NAN): ", 1); output_int(FP_ILOGBNAN == ilogb(NAN), 1); output_char('\n', 1); output_string("M_2: ", 1); output_float(M_E, 1, 4); output_char('\n', 1); output_string("M_LOG2E: ", 1); output_float(M_LOG2E, 1, 4); output_char('\n', 1); output_string("M_LOG10E: ", 1); output_float(M_LOG10E, 1, 4); output_char('\n', 1); output_string("M_LN2: ", 1); output_float(M_LN2, 1, 4); output_char('\n', 1); output_string("M_LN10: ", 1); output_float(M_LN10, 1, 4); output_char('\n', 1); output_string("M_PI: ", 1); output_float(M_PI, 1, 4); output_char('\n', 1); output_string("M_PI_2: ", 1); output_float(M_PI_2, 1, 4); output_char('\n', 1); output_string("M_PI_4: ", 1); output_float(M_PI_4, 1, 4); output_char('\n', 1); output_string("M_1_PI: ", 1); output_float(M_1_PI, 1, 4); output_char('\n', 1); output_string("M_2_PI: ", 1); output_float(M_2_PI, 1, 4); output_char('\n', 1); output_string("M_2_SQRTPI: ", 1); output_float(M_2_SQRTPI, 1, 4); output_char('\n', 1); output_string("M_SQRT2: ", 1); output_float(M_SQRT2, 1, 4); output_char('\n', 1); output_string("M_SQRT1_2: ", 1); output_float(M_SQRT1_2, 1, 4); output_char('\n', 1); for (j = 0; j < p; ++j) { const char *d = values[j].desc ? values[j].desc : "."; output_string(d, 1); output_char(' ', 1); output_float(values[j].d, 1, 4); output_char(' ', 1); output_float(values[j].f, 1, 4); output_char(' ', 1); output_int(values[j].i, 1); output_char(' ', 1); output_int(values[j].l, 1); output_char(' ', 1); output_int(values[j].ll, 1); output_char('\n', 1); } return 0; }
[[]]// XFAIL: *:T sl_def(t_main, void) { sl_sync(); }
int main(int argc, char **argv) { int ret; sl_create(, __main_place_id, ,,,,, t_main); sl_sync(ret); return ret; }
ADVSyncViewManager::ADVSyncViewManager(AnnotatedDNAView* v) : QObject(v), adv(v) { assert(v->getSequenceContexts().isEmpty()); recursion = false; selectionRecursion = false; lockByStartPosAction = new QAction(tr("Lock scales: visible range start"), this); lockByStartPosAction->setObjectName("Lock scales: visible range start"); connect(lockByStartPosAction, SIGNAL(triggered()), SLOT(sl_lock())); lockByStartPosAction->setCheckable(true); lockBySeqSelAction = new QAction(tr("Lock scales: selected sequence"), this); lockBySeqSelAction->setObjectName("Lock scales: selected sequence"); connect(lockBySeqSelAction, SIGNAL(triggered()), SLOT(sl_lock())); lockBySeqSelAction->setCheckable(true); lockByAnnSelAction = new QAction(tr("Lock scales: selected annotation"), this); lockByAnnSelAction->setObjectName("Lock scales: selected annotation"); connect(lockByAnnSelAction, SIGNAL(triggered()), SLOT(sl_lock())); lockByAnnSelAction->setCheckable(true); lockActionGroup = new QActionGroup(this); lockActionGroup->addAction(lockByStartPosAction); lockActionGroup->addAction(lockBySeqSelAction); lockActionGroup->addAction(lockByAnnSelAction); lockActionGroup->setExclusive(true); syncByStartPosAction = new QAction(tr("Adjust scales: visible range start"), this); syncByStartPosAction->setObjectName("Adjust scales: visible range start"); connect(syncByStartPosAction, SIGNAL(triggered()), SLOT(sl_sync())); syncBySeqSelAction = new QAction(tr("Adjust scales: selected sequence"), this); syncBySeqSelAction->setObjectName("Adjust scales: selected sequence"); connect(syncBySeqSelAction, SIGNAL(triggered()), SLOT(sl_sync())); syncByAnnSelAction = new QAction(tr("Adjust scales: selected annotation"), this); syncByAnnSelAction->setObjectName("Adjust scales: selected annotation"); connect(syncByAnnSelAction, SIGNAL(triggered()), SLOT(sl_sync())); lockMenu = new QMenu(tr("Lock scales")); lockMenu->setIcon(QIcon(":core/images/lock_scales.png")); lockMenu->addActions(lockActionGroup->actions()); syncMenu = new QMenu(tr("Adjust scales")); syncMenu->setIcon(QIcon(":core/images/sync_scales.png")); syncMenu->addAction(syncByStartPosAction); syncMenu->addAction(syncBySeqSelAction); syncMenu->addAction(syncByAnnSelAction); lockButton = new QToolButton(); lockButton->setObjectName("Lock scales"); lockButton->setCheckable(true); connect(lockButton, SIGNAL(clicked()), SLOT(sl_lock())); lockButton->setDefaultAction(lockMenu->menuAction()); lockButton->setCheckable(true); syncButton = new QToolButton(); syncButton->setObjectName("Adjust scales"); connect(syncButton, SIGNAL(clicked()), SLOT(sl_sync())); syncButton->setDefaultAction(syncMenu->menuAction()); lockButtonTBAction = NULL; syncButtonTBAction = NULL; // auto-annotations highlighting ops toggleAutoAnnotationsMenu = new QMenu("Global automatic annotation highlighting"); toggleAutoAnnotationsMenu->setIcon(QIcon(":core/images/predefined_annotation_groups.png")); connect( toggleAutoAnnotationsMenu, SIGNAL(aboutToShow()), SLOT(sl_updateAutoAnnotationsMenu()) ); toggleAutoAnnotationsButton = new QToolButton(); toggleAutoAnnotationsButton->setObjectName("toggleAutoAnnotationsButton"); toggleAutoAnnotationsButton->setDefaultAction(toggleAutoAnnotationsMenu->menuAction()); toggleAutoAnnotationsButton->setPopupMode(QToolButton::InstantPopup); toggleAutoAnnotationsAction = NULL; // visual mode ops toggleAllAction = new QAction("Toggle All sequence views", this); toggleAllAction->setObjectName("toggleAllSequenceViews"); connect(toggleAllAction, SIGNAL(triggered()), SLOT(sl_toggleVisualMode())); toggleOveAction = new QAction("Toggle Overview", this); toggleOveAction->setObjectName("toggleOverview"); connect(toggleOveAction, SIGNAL(triggered()), SLOT(sl_toggleVisualMode())); togglePanAction = new QAction("Toggle Zoom view", this); togglePanAction->setObjectName("toggleZoomView"); connect(togglePanAction, SIGNAL(triggered()), SLOT(sl_toggleVisualMode())); toggleDetAction = new QAction("Toggle Details view", this); toggleDetAction->setObjectName("toggleDetailsView"); connect(toggleDetAction, SIGNAL(triggered()), SLOT(sl_toggleVisualMode())); toggleViewButtonAction = NULL; toggleViewButtonMenu = new QMenu(tr("Toggle views")); toggleViewButtonMenu->setIcon(QIcon(":core/images/adv_widget_menu.png")); toggleViewButtonMenu->addAction(toggleAllAction); //-> behavior can be not clear to user toggleViewButtonMenu->addAction(toggleOveAction); toggleViewButtonMenu->addAction(togglePanAction); toggleViewButtonMenu->addAction(toggleDetAction); connect(toggleViewButtonMenu, SIGNAL(aboutToShow()), SLOT(sl_updateVisualMode())); toggleViewButton = new QToolButton(); toggleViewButton->setObjectName("toggleViewButton"); toggleViewButton->setDefaultAction(toggleViewButtonMenu->menuAction()); toggleViewButton->setPopupMode(QToolButton::InstantPopup); updateEnabledState(); connect(adv, SIGNAL(si_sequenceWidgetAdded(ADVSequenceWidget*)), SLOT(sl_sequenceWidgetAdded(ADVSequenceWidget*))); connect(adv, SIGNAL(si_sequenceWidgetRemoved(ADVSequenceWidget*)), SLOT(sl_sequenceWidgetRemoved(ADVSequenceWidget*))); }