static AstExpression CheckUnaryExpression(AstExpression expr) { Type ty; switch (expr->op) { case OP_PREINC: case OP_PREDEC: return TransformIncrement(expr); case OP_ADDRESS: expr->kids[0] = CheckExpression(expr->kids[0]); ty = expr->kids[0]->ty; if (expr->kids[0]->op == OP_DEREF) { expr->kids[0]->kids[0]->lvalue = 0; return expr->kids[0]->kids[0]; } else if (expr->kids[0]->op == OP_INDEX) { expr->kids[0]->op = OP_ADD; expr->kids[0]->ty = PointerTo(ty); expr->kids[0]->lvalue = 0; return expr->kids[0]; } else if (IsFunctionType(ty) || (expr->kids[0]->lvalue && ! expr->kids[0]->bitfld && ! expr->kids[0]->inreg)) { expr->ty = PointerTo(ty); return expr; } break; case OP_DEREF: expr->kids[0] = Adjust(CheckExpression(expr->kids[0]), 1); ty = expr->kids[0]->ty; if (expr->kids[0]->op == OP_ADDRESS) { expr->kids[0]->kids[0]->ty = ty->bty; return expr->kids[0]->kids[0]; } else if (expr->kids[0]->op == OP_ADD && expr->kids[0]->kids[0]->isarray) { expr->kids[0]->op = OP_INDEX; expr->kids[0]->ty = ty->bty; expr->kids[0]->lvalue = 1; return expr->kids[0]; } if (IsPtrType(ty)) { expr->ty = ty->bty; if (IsFunctionType(expr->ty)) { return expr->kids[0]; } expr->lvalue = 1; return expr; } break; case OP_POS: case OP_NEG: expr->kids[0] = Adjust(CheckExpression(expr->kids[0]), 1); if (IsArithType(expr->kids[0]->ty)) { expr->kids[0] = DoIntegerPromotion(expr->kids[0]); expr->ty = expr->kids[0]->ty; return expr->op == OP_POS ? expr->kids[0] : FoldConstant(expr); } break; case OP_COMP: expr->kids[0] = Adjust(CheckExpression(expr->kids[0]), 1); if (IsIntegType(expr->kids[0]->ty)) { expr->kids[0] = DoIntegerPromotion(expr->kids[0]); expr->ty = expr->kids[0]->ty; return FoldConstant(expr); } break; case OP_NOT: expr->kids[0] = Adjust(CheckExpression(expr->kids[0]), 1); if (IsScalarType(expr->kids[0]->ty)) { expr->ty = T(INT); return FoldConstant(expr); } break; case OP_SIZEOF: if (expr->kids[0]->kind == NK_Expression) { expr->kids[0] = CheckExpression(expr->kids[0]); if (expr->kids[0]->bitfld) goto err; ty = expr->kids[0]->ty; } else { ty = CheckTypeName((AstTypeName)expr->kids[0]); } if (IsFunctionType(ty) || ty->size == 0) goto err; expr->ty = T(UINT); expr->op = OP_CONST; expr->val.i[0] = ty->size; return expr; case OP_CAST: return CheckTypeCast(expr); default: assert(0); } err: REPORT_OP_ERROR; }
static T zero() { return T(0); }
static inline void operate(array_nd<T, S>& a, const array<size_t, D>& new_sz, const array<size_t, L>& new_stride, const T& p = T()) { }
void ComponentManager<T>::resetComponent(id entity) { components[unsigned(entitiesComponentsIndex[unsigned(entity)])] = T(); }
void linear_least_squares() { typedef exprtk::symbol_table<T> symbol_table_t; typedef exprtk::expression<T> expression_t; typedef exprtk::parser<T> parser_t; std::string linear_least_squares_program = " if (x[] == y[]) " " { " " beta := (sum(x * y) - sum(x) * sum(y) / x[]) / " " (sum(x^2) - sum(x)^2 / x[]); " " " " alpha := avg(y) - beta * avg(x); " " " " rmse := sqrt(sum((beta * x + alpha - y)^2) / y[]); " " } " " else " " { " " alpha := null; " " beta := null; " " rmse := null; " " } "; T x[] = {T( 1), T( 2), T(3), T( 4), T( 5), T(6), T( 7), T( 8), T( 9), T(10)}; T y[] = {T(8.7), T(6.8), T(6), T(5.6), T(3.8), T(3), T(2.4), T(1.7), T(0.4), T(-1)}; T alpha = T(0); T beta = T(0); T rmse = T(0); symbol_table_t symbol_table; symbol_table.add_variable("alpha",alpha); symbol_table.add_variable("beta" ,beta ); symbol_table.add_variable("rmse" ,rmse ); symbol_table.add_vector ("x" ,x ); symbol_table.add_vector ("y" ,y ); expression_t expression; expression.register_symbol_table(symbol_table); parser_t parser; parser.compile(linear_least_squares_program,expression); expression.value(); printf("alpha: %15.12f\n",alpha); printf("beta: %15.12f\n",beta ); printf("rmse: %15.12f\n",rmse ); printf("y = %15.12fx + %15.12f\n",beta,alpha); }
wnoutrefresh(WINDOW *win) { NCURSES_SIZE_T limit_x; NCURSES_SIZE_T src_row, src_col; NCURSES_SIZE_T begx; NCURSES_SIZE_T begy; NCURSES_SIZE_T dst_row, dst_col; #if USE_SCROLL_HINTS bool wide; #endif #if NCURSES_SP_FUNCS SCREEN *SP_PARM = _nc_screen_of(win); #endif T((T_CALLED("wnoutrefresh(%p)"), (void *) win)); #ifdef TRACE if (USE_TRACEF(TRACE_UPDATE)) { _tracedump("...win", win); _nc_unlock_global(tracef); } #endif /* TRACE */ /* * This function will break badly if we try to refresh a pad. */ if ((win == 0) || (win->_flags & _ISPAD)) returnCode(ERR); /* put them here so "win == 0" won't break our code */ begx = win->_begx; begy = win->_begy; NewScreen(SP_PARM)->_nc_bkgd = win->_nc_bkgd; WINDOW_ATTRS(NewScreen(SP_PARM)) = WINDOW_ATTRS(win); /* merge in change information from all subwindows of this window */ wsyncdown(win); #if USE_SCROLL_HINTS /* * For pure efficiency, we'd want to transfer scrolling information * from the window to newscr whenever the window is wide enough that * its update will dominate the cost of the update for the horizontal * band of newscr that it occupies. Unfortunately, this threshold * tends to be complex to estimate, and in any case scrolling the * whole band and rewriting the parts outside win's image would look * really ugly. So. What we do is consider the window "wide" if it * either (a) occupies the whole width of newscr, or (b) occupies * all but at most one column on either vertical edge of the screen * (this caters to fussy people who put boxes around full-screen * windows). Note that changing this formula will not break any code, * merely change the costs of various update cases. */ wide = (begx <= 1 && win->_maxx >= (NewScreen(SP_PARM)->_maxx - 1)); #endif win->_flags &= ~_HASMOVED; /* * Microtweaking alert! This double loop is one of the genuine * hot spots in the code. Even gcc doesn't seem to do enough * common-subexpression chunking to make it really tense, * so we'll force the issue. */ /* limit(dst_col) */ limit_x = win->_maxx; /* limit(src_col) */ if (limit_x > NewScreen(SP_PARM)->_maxx - begx) limit_x = NewScreen(SP_PARM)->_maxx - begx; for (src_row = 0, dst_row = begy + win->_yoffset; src_row <= win->_maxy && dst_row <= NewScreen(SP_PARM)->_maxy; src_row++, dst_row++) { register struct ldat *nline = &(NewScreen(SP_PARM)->_line[dst_row]); register struct ldat *oline = &win->_line[src_row]; if (oline->firstchar != _NOCHANGE) { int last_src = oline->lastchar; if (last_src > limit_x) last_src = limit_x; src_col = oline->firstchar; dst_col = src_col + begx; if_WIDEC({ register int j; /* * Ensure that we will copy complete multi-column characters * on the left-boundary. */ if (isWidecExt(oline->text[src_col])) { j = 1 + dst_col - WidecExt(oline->text[src_col]); if (j < 0) j = 0; if (dst_col > j) { src_col -= (dst_col - j); dst_col = j; } } /* * Ensure that we will copy complete multi-column characters * on the right-boundary. */ j = last_src; if (WidecExt(oline->text[j])) { ++j; while (j <= limit_x) { if (isWidecBase(oline->text[j])) { break; } else { last_src = j; } ++j; } } }); if_WIDEC({ static cchar_t blank = BLANK; int last_dst = begx + ((last_src < win->_maxx) ? last_src : win->_maxx); int fix_left = dst_col; int fix_right = last_dst; register int j; /* * Check for boundary cases where we may overwrite part of a * multi-column character. For those, wipe the remainder of * the character to blanks. */ j = dst_col; if (isWidecExt(nline->text[j])) { /* * On the left, we only care about multi-column characters * that extend into the changed region. */ fix_left = 1 + j - WidecExt(nline->text[j]); if (fix_left < 0) fix_left = 0; /* only if cell is corrupt */ } j = last_dst; if (WidecExt(nline->text[j]) != 0) { /* * On the right, any multi-column character is a problem, * unless it happens to be contained in the change, and * ending at the right boundary of the change. The * computation for 'fix_left' accounts for the left-side of * this character. Find the end of the character. */ ++j; while (j <= NewScreen(SP_PARM)->_maxx && isWidecExt(nline->text[j])) { fix_right = j++; } } /* * The analysis is simpler if we do the clearing afterwards. * Do that now. */ if (fix_left < dst_col || fix_right > last_dst) { for (j = fix_left; j <= fix_right; ++j) { nline->text[j] = blank; CHANGED_CELL(nline, j); } } });
T tmain(T argc, T *argv) { T b = argc, c, d, e, f, h; T arr[N][10], arr1[N]; T i, j; T s; static T a; // CHECK: static T a; static T g; const T clen = 5; // CHECK: T clen = 5; #pragma omp threadprivate(g) #pragma omp target parallel for simd schedule(dynamic) default(none) linear(a) // CHECK: #pragma omp target parallel for simd schedule(dynamic) default(none) linear(a) for (T i = 0; i < 2; ++i) a = 2; // CHECK-NEXT: for (T i = 0; i < 2; ++i) // CHECK-NEXT: a = 2; #pragma omp target parallel for simd private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) if (parallel :argc) num_threads(N) default(shared) shared(e) reduction(+ : h) for (int i = 0; i < 2; ++i) for (int j = 0; j < 2; ++j) for (int j = 0; j < 2; ++j) for (int j = 0; j < 2; ++j) for (int j = 0; j < 2; ++j) foo(); // CHECK-NEXT: #pragma omp target parallel for simd private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h) // CHECK-NEXT: for (int i = 0; i < 2; ++i) // CHECK-NEXT: for (int j = 0; j < 2; ++j) // CHECK-NEXT: for (int j = 0; j < 2; ++j) // CHECK-NEXT: for (int j = 0; j < 2; ++j) // CHECK-NEXT: for (int j = 0; j < 2; ++j) // CHECK-NEXT: foo(); #pragma omp target parallel for simd default(none), private(argc,b) firstprivate(argv) shared (d) if(parallel:argc > 0) num_threads(N) proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:N][0:10]) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(N) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:N][0:10]) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd if(N) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:N][:argc]) reduction(&& : h) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd if(N) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:N][:argc]) reduction(&&: h) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd if(target:argc > 0) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd if(target: argc > 0) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd if(parallel:argc > 0) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd if(parallel: argc > 0) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd if(N) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd if(N) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd map(i) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd map(tofrom: i) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd map(arr1[0:10], i) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd map(tofrom: arr1[0:10],i) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd map(to: i) map(from: j) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd map(to: i) map(from: j) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd map(always,alloc: i) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd map(always,alloc: i) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd nowait for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd nowait // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd depend(in : argc, arr[i:argc], arr1[:]) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd depend(in : argc,arr[i:argc],arr1[:]) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd defaultmap(tofrom: scalar) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd defaultmap(tofrom: scalar) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd safelen(clen-1) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd safelen(clen - 1) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd simdlen(clen-1) for (T i = 0; i < 2; ++i) {} // CHECK: #pragma omp target parallel for simd simdlen(clen - 1) // CHECK-NEXT: for (T i = 0; i < 2; ++i) { // CHECK-NEXT: } #pragma omp target parallel for simd aligned(arr1:N-1) for (T i = 0; i < N; ++i) {} // CHECK: #pragma omp target parallel for simd aligned(arr1: N - 1) // CHECK-NEXT: for (T i = 0; i < N; ++i) { // CHECK-NEXT: } return T(); }
double E() { return T()+E2(); }
/** * Generate buildUserInterface C++ lines of code corresponding * to user interface widget t */ void Compiler::generateWidgetCode(Tree fulllabel, Tree varname, Tree sig) { Tree path, c, x, y, z; string label; map<string, set<string>> metadata; extractMetadata(tree2str(fulllabel), label, metadata); // add metadata if any for(map<string, set<string>>::iterator i = metadata.begin(); i != metadata.end(); i++) { const string& key = i->first; const set<string>& values = i->second; for(set<string>::const_iterator j = values.begin(); j != values.end(); j++) { fClass->addUICode(subst("interface->declare(&$0, \"$1\", \"$2\");", tree2str(varname), wdel(key), wdel(*j))); fJSON.declare(NULL, wdel(key).c_str(), wdel(*j).c_str()); } } if(isSigButton(sig, path)) { fClass->incUIActiveCount(); fClass->addUICode(subst("interface->addButton(\"$0\", &$1);", checkNullLabel(varname, label), tree2str(varname))); fJSON.addButton(checkNullLabel(varname, label).c_str(), NULL); } else if(isSigCheckbox(sig, path)) { fClass->incUIActiveCount(); fClass->addUICode(subst("interface->addCheckButton(\"$0\", &$1);", checkNullLabel(varname, label), tree2str(varname))); fJSON.addCheckButton(checkNullLabel(varname, label).c_str(), NULL); } else if(isSigVSlider(sig, path, c, x, y, z)) { fClass->incUIActiveCount(); fClass->addUICode(subst("interface->addVerticalSlider(\"$0\", &$1, $2, $3, $4, $5);", checkNullLabel(varname, label), tree2str(varname), T(tree2float(c)), T(tree2float(x)), T(tree2float(y)), T(tree2float(z)))); fJSON.addVerticalSlider(checkNullLabel(varname, label).c_str(), NULL, tree2float(c), tree2float(x), tree2float(y), tree2float(z)); } else if(isSigHSlider(sig, path, c, x, y, z)) { fClass->incUIActiveCount(); fClass->addUICode(subst("interface->addHorizontalSlider(\"$0\", &$1, $2, $3, $4, $5);", checkNullLabel(varname, label), tree2str(varname), T(tree2float(c)), T(tree2float(x)), T(tree2float(y)), T(tree2float(z)))); fJSON.addHorizontalSlider(checkNullLabel(varname, label).c_str(), NULL, tree2float(c), tree2float(x), tree2float(y), tree2float(z)); } else if(isSigNumEntry(sig, path, c, x, y, z)) { fClass->incUIActiveCount(); fClass->addUICode(subst("interface->addNumEntry(\"$0\", &$1, $2, $3, $4, $5);", checkNullLabel(varname, label), tree2str(varname), T(tree2float(c)), T(tree2float(x)), T(tree2float(y)), T(tree2float(z)))); fJSON.addNumEntry(checkNullLabel(varname, label).c_str(), NULL, tree2float(c), tree2float(x), tree2float(y), tree2float(z)); } else if(isSigVBargraph(sig, path, x, y, z)) { fClass->incUIPassiveCount(); fClass->addUICode(subst("interface->addVerticalBargraph(\"$0\", &$1, $2, $3);", checkNullLabel(varname, label, true), tree2str(varname), T(tree2float(x)), T(tree2float(y)))); fJSON.addVerticalBargraph(checkNullLabel(varname, label).c_str(), NULL, tree2float(x), tree2float(y)); } else if(isSigHBargraph(sig, path, x, y, z)) { fClass->incUIPassiveCount(); fClass->addUICode(subst("interface->addHorizontalBargraph(\"$0\", &$1, $2, $3);", checkNullLabel(varname, label, true), tree2str(varname), T(tree2float(x)), T(tree2float(y)))); fJSON.addHorizontalBargraph(checkNullLabel(varname, label).c_str(), NULL, tree2float(x), tree2float(y)); } else { fprintf(stderr, "Error in generating widget code\n"); exit(1); } }
/** * Generate user interface macros corresponding * to a user interface widget */ void Compiler::generateWidgetMacro(const string& pathname, Tree fulllabel, Tree varname, Tree sig) { Tree path, c, x, y, z; string label; map<string, set<string>> metadata; extractMetadata(tree2str(fulllabel), label, metadata); // string pathlabel = pathname+unquote(label); string pathlabel = pathname + label; if(isSigButton(sig, path)) { fClass->addUIMacro(subst("FAUST_ADDBUTTON(\"$0\", $1);", pathlabel, tree2str(varname))); } else if(isSigCheckbox(sig, path)) { fClass->addUIMacro(subst("FAUST_ADDCHECKBOX(\"$0\", $1);", pathlabel, tree2str(varname))); } else if(isSigVSlider(sig, path, c, x, y, z)) { fClass->addUIMacro(subst("FAUST_ADDVERTICALSLIDER(\"$0\", $1, $2, $3, $4, $5);", pathlabel, tree2str(varname), T(tree2float(c)), T(tree2float(x)), T(tree2float(y)), T(tree2float(z)))); } else if(isSigHSlider(sig, path, c, x, y, z)) { fClass->addUIMacro(subst("FAUST_ADDHORIZONTALSLIDER(\"$0\", $1, $2, $3, $4, $5);", pathlabel, tree2str(varname), T(tree2float(c)), T(tree2float(x)), T(tree2float(y)), T(tree2float(z)))); } else if(isSigNumEntry(sig, path, c, x, y, z)) { fClass->addUIMacro(subst("FAUST_ADDNUMENTRY(\"$0\", $1, $2, $3, $4, $5);", pathlabel, tree2str(varname), T(tree2float(c)), T(tree2float(x)), T(tree2float(y)), T(tree2float(z)))); } else if(isSigVBargraph(sig, path, x, y, z)) { fClass->addUIMacro(subst("FAUST_ADDVERTICALBARGRAPH(\"$0\", $1, $2, $3);", pathlabel, tree2str(varname), T(tree2float(x)), T(tree2float(y)))); } else if(isSigHBargraph(sig, path, x, y, z)) { fClass->addUIMacro(subst("FAUST_ADDHORIZONTALBARGRAPH(\"$0\", $1, $2, $3);", pathlabel, tree2str(varname), T(tree2float(x)), T(tree2float(y)))); } else { fprintf(stderr, "Error in generating widget code\n"); exit(1); } }
static T zero() { return T(0.0f); }
T tmain(T argc) { const T d = T(); // expected-note 4 {{'d' defined here}} const T da[5] = {T()}; // expected-note 2 {{'da' defined here}} T qa[5] = {T()}; T i; T &j = i; // expected-note 4 {{'j' defined here}} S3 &p = k; // expected-note 2 {{'p' defined here}} const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}} T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}} T fl; #pragma omp target #pragma omp teams distribute reduction // expected-error {{expected '(' after 'reduction'}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams distribute' are ignored}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(&& : argc) for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(^ : T) // expected-error {{'T' does not refer to a value}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified list item cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(+ : o) // expected-error 2 {{no viable overloaded '='}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} for (int j=0; j<100; j++) foo(); #pragma omp parallel private(k) #pragma omp target #pragma omp teams distribute reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp parallel shared(i) #pragma omp parallel reduction(min : i) #pragma omp target #pragma omp teams distribute reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute reduction(+ : fl) for (int j=0; j<100; j++) foo(); return T(); }
AstExpression DoIntegerPromotion(AstExpression expr) { return expr->ty->categ < INT ? Cast(T(INT), expr) : expr; }
int Get_Hash_Table_Size(Hash_Table *hash_table) { return (T(hash_table)->count); }
static int test() { auto ok = true; #define T(x, y) { \ const uint8_t rmdHex[] = x; \ const uint8_t dataHex[] = y; \ ok = check(ok, rmdHex, dataHex); \ } \ T("9c1185a5c5e9fc54612808977ee8f548b2258d31", ""); T("c151336c3a443e39174958a0c5d45191c3ef1695", "55"); T("dae6e695bca1e174cadd2473a51cd47af1eeb2ea", "7cba"); T("0cd9b2596553a347ef0b76b19dfdd2fc82ab79ea", "4f0344"); T("3e12da39d1c0c6fd61636b1e2d5cbee5593520a7", "56edf52a"); T("e6dc6fb08bc890b14ad1a9b76838be6d0d91a7ef", "2fd14ffb71"); T("828c499b385e5124043756ed0f0e158c50cbb6b7", "00cabaaed8a3"); T("f08e3dcc9a5e85f01d6a6c9587fa346e004f7eab", "b1e4e106a7dc98"); T("0337e23d47b24e7725550017c2fd5c9a981a22e2", "ccddcf3f146f1e1b"); T("2a60e7be7f55d77a6c045cc04d7ecf9386793d84", "27e705ad7bfae3115d"); T("a31b6c0bb8b396583df8e7033ca720f8f850f925", "c364cd75e689076bf902"); T("11d989e645eb3b35afbaf669f4565ba5272dbc06", "9dd4506aefe57cfdbebc86"); T("76b6cde640d22792c36d9dd9f13f8465a890847b", "85770ea2816348571f2fac04"); T("815d572be48544d004e20107732b0165878b1648", "9ff484003dc220a8704825b388"); T("2cd79e19c8f20c19956f13d3a8e34906ac997060", "6e2f95217987955d60ec08a5f5c2"); T("3c88a5d90c6cc64bf5944ab4360e6ed9d509ebe0", "514a8231f357c5618dba971868a17f"); T("bdadc1a25c2403664cd52c6f0e4619e5c572ae3b", "bf0c47add4a42758d7add4610b7d8992"); T("37a49f54e851a76464fe9362fcdb3ff6033c7265", "171a4cb594af5a4fc9c7cb39d47405e652"); T("95e1d2b60e2a08d1e4cafbf35ca249a0f23a5607", "38f62f7c93859eb9d526f00438daea640882"); T("2eec9e33479373cf29d1bcffc1736cfc14dda837", "4adb13a38862751c139a02f4d304024bf8ca26"); T("6c7e5e620347d7063231bd4b5fdafd10c16f5705", "09eb70bc4c043d4c8a10e75c68f666f6c0971e4d"); T("8d1d19625c4e619758840d397fde7c2b75f68ef0", "b5d3adedff45ec14f6ba6358b9ef011b13faeea2f0"); T("a020e24896cccc1c4208a5111651846b32fb55b7", "a97d9cbe1bba8c29fc97877d591d4c7fc09ae74611d3"); T("6d7aed7f598b70c86af766894c23455a41dbd255", "0969e7aa199ab108023445c2f2d3e14cc75e60f909ce8f"); T("07f7642778d7e043ba1a03fd9a6ab11b570e3e21", "ab835fb637a31176e90915602b92bc8a6c68a1e2f94e7b06"); T("a86975e09018f7d0f908ede71665a60bd445f930", "60980bee2273a2d7f9bd52644438d8dc82fd8d182d287f8145"); T("f70515fe49e269db69d039ed14d30f6b8b2fcb0d", "32cfb09b8f6d3d27e5717fe97d17bde5e4bb076dbfa036d33de5"); T("58c90cfa8f0d45f3e756b04583f3482ab94e7bf6", "37413e8302e463e0fa92d6ef7b0ab410b013b635553c2be73654e8"); T("ea35dc191b185b65ca24c2c72411bf2e0d225063", "b763f812c8a557edd6195afa288a3ea450cbc594362217288ee8bfb0"); T("23c66ab656cf14d5aa62a3a6577f706eecfd6d49", "623beb472d62e118c8ad23f5e229ffe6069f940ccc9c9a0b02ddf19ea7"); #undef T return ok ? 0 : 1; }
char *Get_Hash_String(Hash_Table *hash_table, int i) { return (T(hash_table)->strings + T(hash_table)->cells[i].text); }
S (T t = T ()): t_ (t) { } // must zero initialize `t' if POD
// that guarantees safe initialization of the static variable. typedef mpl::bool_<(bernoulli_imp_variant<T>::value >= 1) && (bernoulli_imp_variant<T>::value <= 3)> tag_type; static const std::size_t lim = find_bernoulli_overflow_limit<T, Policy>(tag_type()); return lim; } // // The tangent numbers grow larger much more rapidly than the Bernoulli numbers do.... // so to compute the Bernoulli numbers from the tangent numbers, we need to avoid spurious // overflow in the calculation, we can do this by scaling all the tangent number by some scale factor: // template <class T> inline typename enable_if_c<std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::radix == 2), T>::type tangent_scale_factor() { BOOST_MATH_STD_USING return ldexp(T(1), std::numeric_limits<T>::min_exponent + 5); } template <class T> inline typename disable_if_c<std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::radix == 2), T>::type tangent_scale_factor() { return tools::min_value<T>() * 16; } // // Initializer: ensure all our constants are initialized prior to the first call of main: // template <class T, class Policy> struct bernoulli_initializer { struct init { init()
inline void SymmRUA ( T alpha, const DistMatrix<T>& A, const DistMatrix<T>& B, T beta, DistMatrix<T>& C, bool conjugate=false ) { #ifndef RELEASE PushCallStack("internal::SymmRUA"); if( A.Grid() != B.Grid() || B.Grid() != C.Grid() ) throw std::logic_error ("{A,B,C} must be distributed over the same grid"); #endif const Grid& g = A.Grid(); const Orientation orientation = ( conjugate ? ADJOINT : TRANSPOSE ); DistMatrix<T> BT(g), B0(g), BB(g), B1(g), B2(g); DistMatrix<T> CT(g), C0(g), CB(g), C1(g), C2(g); DistMatrix<T,MR, STAR> B1Trans_MR_STAR(g); DistMatrix<T,VC, STAR> B1Trans_VC_STAR(g); DistMatrix<T,STAR,MC > B1_STAR_MC(g); DistMatrix<T,MC, STAR> Z1Trans_MC_STAR(g); DistMatrix<T,MR, STAR> Z1Trans_MR_STAR(g); DistMatrix<T,MC, MR > Z1Trans(g); DistMatrix<T,MR, MC > Z1Trans_MR_MC(g); B1Trans_MR_STAR.AlignWith( A ); B1Trans_VC_STAR.AlignWith( A ); B1_STAR_MC.AlignWith( A ); Z1Trans_MC_STAR.AlignWith( A ); Z1Trans_MR_STAR.AlignWith( A ); Matrix<T> Z1Local; Scale( beta, C ); LockedPartitionDown ( B, BT, BB, 0 ); PartitionDown ( C, CT, CB, 0 ); while( CT.Height() < C.Height() ) { LockedRepartitionDown ( BT, B0, /**/ /**/ B1, BB, B2 ); RepartitionDown ( CT, C0, /**/ /**/ C1, CB, C2 ); Z1Trans_MR_MC.AlignWith( C1 ); Zeros( C1.Width(), C1.Height(), Z1Trans_MC_STAR ); Zeros( C1.Width(), C1.Height(), Z1Trans_MR_STAR ); //--------------------------------------------------------------------// B1Trans_MR_STAR.TransposeFrom( B1, conjugate ); B1Trans_VC_STAR = B1Trans_MR_STAR; B1_STAR_MC.TransposeFrom( B1Trans_VC_STAR, conjugate ); LocalSymmetricAccumulateRU ( orientation, alpha, A, B1_STAR_MC, B1Trans_MR_STAR, Z1Trans_MC_STAR, Z1Trans_MR_STAR ); Z1Trans.SumScatterFrom( Z1Trans_MC_STAR ); Z1Trans_MR_MC = Z1Trans; Z1Trans_MR_MC.SumScatterUpdate( T(1), Z1Trans_MR_STAR ); Transpose( Z1Trans_MR_MC.LockedMatrix(), Z1Local, conjugate ); Axpy( T(1), Z1Local, C1.Matrix() ); //--------------------------------------------------------------------// Z1Trans_MR_MC.FreeAlignments(); SlideLockedPartitionDown ( BT, B0, B1, /**/ /**/ BB, B2 ); SlidePartitionDown ( CT, C0, C1, /**/ /**/ CB, C2 ); } #ifndef RELEASE PopCallStack(); #endif }
int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br) { short i; short endx, endy; T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), win, _tracechtype2(1,ls), _tracechtype2(2,rs), _tracechtype2(3,ts), _tracechtype2(4,bs), _tracechtype2(5,tl), _tracechtype2(6,tr), _tracechtype2(7,bl), _tracechtype2(8,br))); if (!win) returnCode(ERR); if (ls == 0) ls = ACS_VLINE; if (rs == 0) rs = ACS_VLINE; if (ts == 0) ts = ACS_HLINE; if (bs == 0) bs = ACS_HLINE; if (tl == 0) tl = ACS_ULCORNER; if (tr == 0) tr = ACS_URCORNER; if (bl == 0) bl = ACS_LLCORNER; if (br == 0) br = ACS_LRCORNER; ls = _nc_render(win, ls); rs = _nc_render(win, rs); ts = _nc_render(win, ts); bs = _nc_render(win, bs); tl = _nc_render(win, tl); tr = _nc_render(win, tr); bl = _nc_render(win, bl); br = _nc_render(win, br); T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", ls, rs, ts, bs, tl, tr, bl, br)); endx = win->_maxx; endy = win->_maxy; for (i = 0; i <= endx; i++) { win->_line[0].text[i] = ts; win->_line[endy].text[i] = bs; } win->_line[endy].firstchar = win->_line[0].firstchar = 0; win->_line[endy].lastchar = win->_line[0].lastchar = endx; for (i = 0; i <= endy; i++) { win->_line[i].text[0] = ls; win->_line[i].text[endx] = rs; win->_line[i].firstchar = 0; win->_line[i].lastchar = endx; } win->_line[0].text[0] = tl; win->_line[0].text[endx] = tr; win->_line[endy].text[0] = bl; win->_line[endy].text[endx] = br; _nc_synchook(win); returnCode(OK); }
inline void LocalSymmetricAccumulateRU ( Orientation orientation, T alpha, const DistMatrix<T,MC, MR >& A, const DistMatrix<T,STAR,MC >& B_STAR_MC, const DistMatrix<T,MR, STAR>& BTrans_MR_STAR, DistMatrix<T,MC, STAR>& ZTrans_MC_STAR, DistMatrix<T,MR, STAR>& ZTrans_MR_STAR ) { #ifndef RELEASE PushCallStack("internal::LocalSymmetricAccumulateRU"); if( A.Grid() != B_STAR_MC.Grid() || B_STAR_MC.Grid() != BTrans_MR_STAR.Grid() || BTrans_MR_STAR.Grid() != ZTrans_MC_STAR.Grid() || ZTrans_MC_STAR.Grid() != ZTrans_MR_STAR.Grid() ) throw std::logic_error ("{A,B,C} must be distributed over the same grid"); if( A.Height() != A.Width() || A.Height() != B_STAR_MC.Width() || A.Height() != BTrans_MR_STAR.Height() || A.Height() != ZTrans_MC_STAR.Height() || A.Height() != ZTrans_MR_STAR.Height() || B_STAR_MC.Height() != BTrans_MR_STAR.Width() || BTrans_MR_STAR.Width() != ZTrans_MC_STAR.Width() || ZTrans_MC_STAR.Width() != ZTrans_MR_STAR.Width() ) { std::ostringstream msg; msg << "Nonconformal LocalSymmetricAccumulateRU: \n" << " A ~ " << A.Height() << " x " << A.Width() << "\n" << " B[* ,MC] ~ " << B_STAR_MC.Height() << " x " << B_STAR_MC.Width() << "\n" << " B^H/T[MR,* ] ~ " << BTrans_MR_STAR.Height() << " x " << BTrans_MR_STAR.Width() << "\n" << " Z^H/T[MC,* ] ~ " << ZTrans_MC_STAR.Height() << " x " << ZTrans_MC_STAR.Width() << "\n" << " Z^H/T[MR,* ] ~ " << ZTrans_MR_STAR.Height() << " x " << ZTrans_MR_STAR.Width() << "\n"; throw std::logic_error( msg.str().c_str() ); } if( B_STAR_MC.RowAlignment() != A.ColAlignment() || BTrans_MR_STAR.ColAlignment() != A.RowAlignment() || ZTrans_MC_STAR.ColAlignment() != A.ColAlignment() || ZTrans_MR_STAR.ColAlignment() != A.RowAlignment() ) throw std::logic_error("Partial matrix distributions are misaligned"); #endif const Grid& g = A.Grid(); // Matrix views DistMatrix<T> ATL(g), ATR(g), A00(g), A01(g), A02(g), ABL(g), ABR(g), A10(g), A11(g), A12(g), A20(g), A21(g), A22(g); DistMatrix<T> D11(g); DistMatrix<T,STAR,MC> BL_STAR_MC(g), BR_STAR_MC(g), B0_STAR_MC(g), B1_STAR_MC(g), B2_STAR_MC(g); DistMatrix<T,MR,STAR> BTTrans_MR_STAR(g), B0Trans_MR_STAR(g), BBTrans_MR_STAR(g), B1Trans_MR_STAR(g), B2Trans_MR_STAR(g); DistMatrix<T,MC,STAR> ZTTrans_MC_STAR(g), Z0Trans_MC_STAR(g), ZBTrans_MC_STAR(g), Z1Trans_MC_STAR(g), Z2Trans_MC_STAR(g); DistMatrix<T,MR,STAR> ZBTrans_MR_STAR(g), Z0Trans_MR_STAR(g), ZTTrans_MR_STAR(g), Z1Trans_MR_STAR(g), Z2Trans_MR_STAR(g); const int ratio = std::max( g.Height(), g.Width() ); PushBlocksizeStack( ratio*Blocksize() ); LockedPartitionDownDiagonal ( A, ATL, ATR, ABL, ABR, 0 ); LockedPartitionRight( B_STAR_MC, BL_STAR_MC, BR_STAR_MC, 0 ); LockedPartitionDown ( BTrans_MR_STAR, BTTrans_MR_STAR, BBTrans_MR_STAR, 0 ); PartitionDown ( ZTrans_MC_STAR, ZTTrans_MC_STAR, ZBTrans_MC_STAR, 0 ); PartitionDown ( ZTrans_MR_STAR, ZTTrans_MR_STAR, ZBTrans_MR_STAR, 0 ); while( ATL.Height() < A.Height() ) { LockedRepartitionDownDiagonal ( ATL, /**/ ATR, A00, /**/ A01, A02, /*************/ /******************/ /**/ A10, /**/ A11, A12, ABL, /**/ ABR, A20, /**/ A21, A22 ); LockedRepartitionRight ( BL_STAR_MC, /**/ BR_STAR_MC, B0_STAR_MC, /**/ B1_STAR_MC, B2_STAR_MC ); LockedRepartitionDown ( BTTrans_MR_STAR, B0Trans_MR_STAR, /***************/ /***************/ B1Trans_MR_STAR, BBTrans_MR_STAR, B2Trans_MR_STAR ); RepartitionDown ( ZTTrans_MC_STAR, Z0Trans_MC_STAR, /***************/ /***************/ Z1Trans_MC_STAR, ZBTrans_MC_STAR, Z2Trans_MC_STAR ); RepartitionDown ( ZTTrans_MR_STAR, Z0Trans_MR_STAR, /***************/ /***************/ Z1Trans_MR_STAR, ZBTrans_MR_STAR, Z2Trans_MR_STAR ); D11.AlignWith( A11 ); //--------------------------------------------------------------------// D11 = A11; MakeTriangular( UPPER, D11 ); LocalGemm ( orientation, orientation, alpha, D11, B1_STAR_MC, T(1), Z1Trans_MR_STAR ); SetDiagonal( D11, T(0) ); LocalGemm ( NORMAL, NORMAL, alpha, D11, B1Trans_MR_STAR, T(1), Z1Trans_MC_STAR ); LocalGemm ( orientation, orientation, alpha, A12, B1_STAR_MC, T(1), Z2Trans_MR_STAR ); LocalGemm ( NORMAL, NORMAL, alpha, A12, B2Trans_MR_STAR, T(1), Z1Trans_MC_STAR ); //--------------------------------------------------------------------// D11.FreeAlignments(); SlideLockedPartitionDownDiagonal ( ATL, /**/ ATR, A00, A01, /**/ A02, /**/ A10, A11, /**/ A12, /*************/ /******************/ ABL, /**/ ABR, A20, A21, /**/ A22 ); SlideLockedPartitionRight ( BL_STAR_MC, /**/ BR_STAR_MC, B0_STAR_MC, B1_STAR_MC, /**/ B2_STAR_MC ); SlideLockedPartitionDown ( BTTrans_MR_STAR, B0Trans_MR_STAR, B1Trans_MR_STAR, /***************/ /***************/ BBTrans_MR_STAR, B2Trans_MR_STAR ); SlidePartitionDown ( ZTTrans_MC_STAR, Z0Trans_MC_STAR, Z1Trans_MC_STAR, /***************/ /***************/ ZBTrans_MC_STAR, Z2Trans_MC_STAR ); SlidePartitionDown ( ZTTrans_MR_STAR, Z0Trans_MR_STAR, Z1Trans_MR_STAR, /***************/ /***************/ ZBTrans_MR_STAR, Z2Trans_MR_STAR ); } PopBlocksizeStack(); #ifndef RELEASE PopCallStack(); #endif }
void resize_rearrange(array_nd<T, S>& a, const array<size_t, D>& new_sz, const array<size_t, L>& new_stride, bool pad = false, const T& padval = T()) { bool skip_flag = true; size_t dm = std::min(size_t(a.ndims()), size_t(new_sz.length())); array<index_array, tiny> id(a.ndims()); for(size_t i = dm; i < a.ndims(); i++) id[i] = idx(0); array<size_t, tiny> junc(dm); for(size_t i = 0; i < dm; i++) junc[i] = std::min(new_sz[i], a.size_nd(i)); for(size_t i = 0; i < dm; i++) { // should some dims be reverse and some not if(a.stride(i) >= new_stride[i]) id[i] = size_range(0, junc[i] - 1); else id[i] = size_range(junc[i] - 1, 0); if(a.stride(i) != new_stride[i] && !(new_sz[i] == 1) && !(a.size_nd(i) == 1)) skip_flag = false; } // if data is in the same position, it needs no repositioning. if(!skip_flag) { // shape of the old array, but with same number of dims as the new array array<size_t, tiny> new_szm(a.ndims(), 1); size_range new_szr(0, std::min(new_sz.length() - 1, a.ndims() - 1)); new_szm[new_szr] = new_sz[new_szr]; // performs shape manipulation on the array without resizing it: array_nd<T, data::ref_iterator<array_nd<T, S> > > new_arr(new_szm/* */, a); //new_arr.init(a); //TODO: ivl::serial(.) //and worry about dimension sorting force(new_arr(id)) = a(id); } if(pad) { id.resize(new_sz.length(), idx(0)); array_nd<T, data::ref_iterator<array_nd<T, S> > > new_arr(new_sz, a); // padding common dimensions for(size_t i = 0; i < dm; i++) { id[i] = size_range(junc[i], new_sz[i] - 1); new_arr(id) = padval; id[i] = index_all(); } // padding extra dimensions for(size_t i = dm; i < new_sz.length(); i++) { id[i] = size_range(1, new_sz[i] - 1); new_arr(id) = padval; id[i] = index_all(); } } }
inline void SymmRUC ( T alpha, const DistMatrix<T>& A, const DistMatrix<T>& B, T beta, DistMatrix<T>& C, bool conjugate=false ) { #ifndef RELEASE PushCallStack("internal::SymmRUC"); if( A.Grid() != B.Grid() || B.Grid() != C.Grid() ) throw std::logic_error("{A,B,C} must be distributed on the same grid"); #endif const Grid& g = A.Grid(); const Orientation orientation = ( conjugate ? ADJOINT : TRANSPOSE ); // Matrix views DistMatrix<T> ATL(g), ATR(g), A00(g), A01(g), A02(g), AColPan(g), ABL(g), ABR(g), A10(g), A11(g), A12(g), ARowPan(g), A20(g), A21(g), A22(g); DistMatrix<T> BL(g), BR(g), B0(g), B1(g), B2(g); DistMatrix<T> CL(g), CR(g), C0(g), C1(g), C2(g), CLeft(g), CRight(g); // Temporary distributions DistMatrix<T,MC, STAR> B1_MC_STAR(g); DistMatrix<T,VR, STAR> AColPan_VR_STAR(g); DistMatrix<T,STAR,MR > AColPanTrans_STAR_MR(g); DistMatrix<T,MR, STAR> ARowPanTrans_MR_STAR(g); B1_MC_STAR.AlignWith( C ); // Start the algorithm Scale( beta, C ); LockedPartitionDownDiagonal ( A, ATL, ATR, ABL, ABR, 0 ); LockedPartitionRight( B, BL, BR, 0 ); PartitionRight( C, CL, CR, 0 ); while( CR.Width() > 0 ) { LockedRepartitionDownDiagonal ( ATL, /**/ ATR, A00, /**/ A01, A02, /*************/ /******************/ /**/ A10, /**/ A11, A12, ABL, /**/ ABR, A20, /**/ A21, A22 ); LockedRepartitionRight ( BL, /**/ BR, B0, /**/ B1, B2 ); RepartitionRight ( CL, /**/ CR, C0, /**/ C1, C2 ); LockedView1x2( ARowPan, A11, A12 ); LockedView2x1 ( AColPan, A01, A11 ); View1x2( CLeft, C0, C1 ); View1x2( CRight, C1, C2 ); AColPan_VR_STAR.AlignWith( CLeft ); AColPanTrans_STAR_MR.AlignWith( CLeft ); ARowPanTrans_MR_STAR.AlignWith( CRight ); //--------------------------------------------------------------------// B1_MC_STAR = B1; AColPan_VR_STAR = AColPan; AColPanTrans_STAR_MR.TransposeFrom( AColPan_VR_STAR, conjugate ); ARowPanTrans_MR_STAR.TransposeFrom( ARowPan, conjugate ); MakeTriangular( LOWER, ARowPanTrans_MR_STAR ); MakeTrapezoidal( RIGHT, LOWER, -1, AColPanTrans_STAR_MR ); LocalGemm ( NORMAL, orientation, alpha, B1_MC_STAR, ARowPanTrans_MR_STAR, T(1), CRight ); LocalGemm ( NORMAL, NORMAL, alpha, B1_MC_STAR, AColPanTrans_STAR_MR, T(1), CLeft ); //--------------------------------------------------------------------// AColPan_VR_STAR.FreeAlignments(); AColPanTrans_STAR_MR.FreeAlignments(); ARowPanTrans_MR_STAR.FreeAlignments(); SlideLockedPartitionDownDiagonal ( ATL, /**/ ATR, A00, A01, /**/ A02, /**/ A10, A11, /**/ A12, /*************/ /******************/ ABL, /**/ ABR, A20, A21, /**/ A22 ); SlideLockedPartitionRight ( BL, /**/ BR, B0, B1, /**/ B2 ); SlidePartitionRight ( CL, /**/ CR, C0, C1, /**/ C2 ); } #ifndef RELEASE PopCallStack(); #endif }
void ComponentManager<T>::createComponent(id entity) { assert(entitiesComponentsIndex.size() > entity && "ComponentManager: entity out of range"); entitiesComponentsIndex[entity] = int(components.size()); components.push_back(T()); }
operator T() { return T(); }
//============================================================================== void DrawablePad::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) { const int insetX = getWidth() / 4; const int insetY = getHeight() / 4; Rectangle imageSpace; imageSpace.setBounds (insetX, insetY, getWidth() - insetX * 2, getHeight() - insetY * 2); drawButtonBackground (g, *this, getBackgroundColour(), isMouseOverButton, isButtonDown); g.setOpacity (1.0f); const Drawable* imageToDraw = 0; if (isEnabled()) { imageToDraw = getCurrentImage(); } else { imageToDraw = getToggleState() ? disabledImageOn : disabledImage; if (imageToDraw == 0) { g.setOpacity (0.4f); imageToDraw = getNormalImage(); } } if (imageToDraw != 0) { g.setImageResamplingQuality (Graphics::highResamplingQuality); imageToDraw->drawWithin (g, imageSpace.getX(), imageSpace.getY(), imageSpace.getWidth(), imageSpace.getHeight(), RectanglePlacement::centred, 1.0f); } float fontsize = jmin ((float)(proportionOfWidth(0.2f)),(float)(proportionOfHeight(0.15f))); if (fontsize < 5.0) fontsize=5.0; g.setFont (Font (fontsize, Font::bold)); g.setColour (getBackgroundColour().contrasting(0.8f)); g.drawText (Label, proportionOfWidth (0.0447f), proportionOfHeight (0.0499f), proportionOfWidth (0.9137f), proportionOfHeight (0.1355f), Justification::centred, true); if (showdot && ! hex) { g.setFont (Font (fontsize*0.9f, Font::plain)); String xy; if (showx && showy) xy = T("x:") + String((int)(x*127.1)) + T(" y:") + String((int)(y*127.1)); else if (showx) xy = T("x:") + String((int)(x*127.1)); else if (showy) xy = T("y:") + String((int)(y*127.1)); g.drawText (xy, proportionOfWidth (0.0447f), proportionOfHeight (0.8057f), proportionOfWidth (0.9137f), proportionOfHeight (0.1355f), Justification::centred, true); float diameter = jmin ((float)(proportionOfHeight(0.125f)), (float)(proportionOfWidth(0.5f))); g.setColour (Colour (0x88faa52a)); g.fillEllipse ((float)(proportionOfWidth(x)) - diameter*0.5f, (float)(proportionOfHeight(1.0f-y)) - diameter*0.5f, diameter, diameter); g.setColour (Colour (0x99a52a88)); g.drawEllipse ((float)(proportionOfWidth(x)) - diameter*0.5f, (float)(proportionOfHeight(1.0f-y)) - diameter*0.5f, diameter, diameter, diameter*0.1f); } }
NT2_TEST_CASE_TPL( ctranspose_scalar, NT2_TYPES ) { NT2_TEST_EQUAL(nt2::ctranspose(T(1)), T(1)); }