コード例 #1
0
void fooz()
{
  auto plugh = [](int *A, int *B, int i) { A[i] += B[i]; };
  int n =64;
  int a[n],b[n];

  #pragma omp target map(tofrom:a[:n],b[:n])
  {
    auto bar = [](int *A, int *B, int i ) { A[i] += B[i]; };

    for (int i = 0;  i < n; ++ i)
      plugh(a, b, i);
    for (int i = 0;  i < n; ++ i)
      bar(b, a, i);

    funky(a, b, n, plugh);

    funky(a, b, n, bar);
}
  // CK3:    %class.anon* dereferenceable(1) %plugh
  // CK3:    %plugh.addr = alloca %class.anon*, align 8
  // CK3:    %bar = alloca %class.anon.0, align 1
  // CK3:    store %class.anon* %plugh, %class.anon** %plugh.addr, align 8
  // CK3:    call void @"_{{.+}}funky{{.+}}fooz{{.+}}
  // CK3:    call void @"_{{.+}}funky
  // CK3:    define {{.*}}void @"_{{.+}}funky{{.+}}fooz
  // CK3:    define {{.*}}void @"_{{.+}}funky

}
コード例 #2
0
ファイル: pro.cpp プロジェクト: qbolec/c
long dictsize2()
{
  goodness2[1].kdo[0]=1;
  goodness2[2].kdo[1]=1;
  goodness2[2].kdo[0]=-1;
  for(int i=3;i<=m;i++)
  {
     //wyliczmy wartosc goodness2[i]:
     //1.sumujemy wczesniejsze
     for(int e=1;e<l;e++)
        if(i-e>0)
        {
           add( i-e, i );//(skad,dokad)
        }
     //2.wymnarzamy przez k-1
     funky( i);
  }
  //ostatecznym wynikiem jest suma razy k;
  for(int e=1;e<l;e++)
     add(m-e+1,0);
  shiftup(0);
  converttobin();
}
コード例 #3
0
ファイル: whirlygig.c プロジェクト: MaddTheSane/xscreensaver
static unsigned long
whirlygig_draw (Display *dpy, Window window, void *closure)
{
  struct state *st = (struct state *) closure;
  int wcount;  /* wcount is a counter incremented for every whirly take note of
                  internal_time before you mess with it */
  int change_time = 4000;

  if (st->explaining == 1) {
    XClearWindow (st->dpy, st->window);
    draw_explain_string(st, st->xmode, st->info->half_height-100, 
                        st->dpy, st->window, st->fgc);
    st->explaining++;
    return 3000000;
  } else if (st->explaining == 2) {
    XClearWindow (st->dpy, st->window);
    st->explaining = 0;
  }

  if (! strcmp (st->xmode_str, "change") && ! strcmp (st->ymode_str, "change")) {
    if ((st->current_time - st->start_time) > change_time) {
      st->start_time = st->current_time;
      st->xmode = 1 + (random() % 4);
      st->ymode = 1 + (random() % 4);
    }
  }
  else if (! strcmp (st->xmode_str, "change")) {
    if ((st->current_time - st->start_time) > change_time) {
      st->start_time = st->current_time;
      st->xmode = 1 + (random() % 4);
    }
  }
  else if (! strcmp (st->ymode_str, "change")) {
    if ((st->current_time - st->start_time) > change_time) {
      st->start_time = st->current_time;
      st->ymode = 1 + (random() % 3);
      printf("Changing ymode to %d\n", st->ymode);
    }
  }
  if (++st->current_color >= NCOLORS)
    st->current_color = 0;
  for (wcount = 0; wcount < st->info->whirlies; wcount++) {
    int lcount; /* lcount is a counter for every line -- take note of the offsets changing */
    int internal_time = 0;
    int color_offset = (st->current_color + (st->info->color_modifier * wcount)) % NCOLORS;
    if (st->current_time != 0)
      /* I want the distance between whirlies to increase more each whirly */
      internal_time = st->current_time + (10 * wcount) + (wcount * wcount); 
    switch (st->xmode) {
      /* All these functions expect an int time, the struct info,
         a pointer to an array of positions, and the index that the 
         the function will fill of the array */
    case spin_mode:
      spin(st, internal_time, st->info, st->pos, 0);
      break;
    case funky_mode:
      funky(st, internal_time, st->info, st->pos, 0);
      break;
    case circle_mode:
      circle(st, internal_time, st->info, st->pos, 0);
      break;
    case linear_mode:
      linear(st, internal_time, st->info, st->pos, 0);
      break;
    case fun_mode:
      fun(st, internal_time, st->info, st->pos, 0);
      break;
    case test_mode:
      test(st, internal_time, st->info, st->pos, 0);
      break;
    case innie_mode:
      innie(st, internal_time, st->info, st->pos, 0, st->modifier);
      break;
    case lissajous_mode:
      lissajous(st, internal_time, st->info, st->pos, 0);
      break;
    default:
      spin(st, internal_time, st->info, st->pos, 0);
      break;
    }   /* End of the switch for the x position*/
    switch (st->ymode) {
    case spin_mode:
      spin(st, internal_time, st->info, st->pos, 1);
      break;
    case funky_mode:
      funky(st, internal_time, st->info, st->pos, 1);
      break;
    case circle_mode:
      circle(st, internal_time, st->info, st->pos, 1);
      break;
    case linear_mode:
      linear(st, internal_time, st->info, st->pos, 1);
      break;
    case fun_mode:
      fun(st, internal_time, st->info, st->pos, 1);
      break;
    case test_mode:
      test(st, internal_time, st->info, st->pos, 1);
      break;
    case innie_mode:
      innie(st, internal_time, st->info, st->pos, 1, st->modifier);
      break;
    case lissajous_mode:
      lissajous(st, internal_time, st->info, st->pos, 1);
      break;
    default:
      spin(st, internal_time, st->info, st->pos, 1);
      break;
    } /* End of the switch for the y position*/
    for (lcount = 0; lcount < st->info->nlines; lcount++) {
      double arg = (double)((internal_time * st->info->offset_period) / 90.0); 
      double line_offset = 20.0 * (double)lcount * sin(arg); 
      int size;
      size = (int)(15.0 + 5.0 * sin((double)internal_time / 180.0));
      /* First delete the old circle... */
      if (!st->info->trail
#ifdef HAVE_DOUBLE_BUFFER_EXTENSION
          && ( !st->dbeclear_p || !st->backb)
#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */
          ) {
        XSetForeground(st->dpy, st->bgc, BlackPixel(st->dpy, st->screen));
        XFillArc(st->dpy, st->b, st->bgc, st->last_x[wcount][lcount], st->last_y[wcount][lcount], st->last_size[wcount][lcount], st->last_size[wcount][lcount], START_ARC, END_ARC);
      }
      /* Now, lets draw in the new circle */
      {  /* Starting new scope for local x_pos and y_pos */
        int xpos, ypos;
        if (st->wrap) {
          xpos = preen((int)(st->info->xoffset*line_offset)+st->pos[0], st->info->half_width * 2);
          ypos = preen((int)(st->info->yoffset*line_offset)+st->pos[1], st->info->half_height * 2);
        }
        else {
          xpos = (int)(st->info->xoffset*line_offset)+st->pos[0];
          ypos = (int)(st->info->yoffset*line_offset)+st->pos[1]; 
        }
        if (st->start_time == st->current_time) {
          /* smoothen should move from one mode to another prettily... */

          /* Note: smoothen has not been modified to take the double
             buffering code into account, and needs to be hacked on
             before uncommenting.
          */
          /* 
             smoothen(xpos, last_x[wcount][lcount], ypos, last_y[wcount][lcount], size, color_offset, colors, dpy, window, bgc, screen, info);
          */
        }
        st->last_x[wcount][lcount] = xpos;
        st->last_y[wcount][lcount] = ypos;
        st->last_size[wcount][lcount] = size;
        XSetForeground(st->dpy, st->bgc, st->colors[color_offset].pixel);
        XFillArc(st->dpy, st->b, st->bgc, xpos, ypos, size, size, START_ARC, END_ARC);
      } /* End of my temporary scope for xpos and ypos */
    }  /* End of the for each line in nlines */
  } /* End of the for each whirly in whirlies */


#ifdef HAVE_DOUBLE_BUFFER_EXTENSION
  if (st->backb)
    {
      XdbeSwapInfo info[1];
      info[0].swap_window = st->window;
      info[0].swap_action = (st->dbeclear_p ? XdbeBackground : XdbeUndefined);
      XdbeSwapBuffers (st->dpy, info, 1);
    }
  else
#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */
    if (st->dbuf)
      {
        XCopyArea (st->dpy, st->b, st->window, st->bgc, 0, 0,
                   st->xgwa.width, st->xgwa.height, 0, 0);
      }

  if (st->current_time == FULL_CYCLE)
    st->current_time = 1;
  else
    st->current_time = st->current_time + st->info->speed;

  return 10000;
}
コード例 #4
0
ファイル: constexpr-noexcept5.C プロジェクト: Nodplus/gcc
int main() {
  funky();
  return 0;
}
コード例 #5
0
ファイル: main.cpp プロジェクト: CCJY/coliru
void func() {
    Derived d;
    d.vptr = &DerivedVTable;

    funky(&d);
}