Exemplo n.º 1
0
{
  return NULL;
}

static void
handler (int sig)
{
}

static void __attribute__ ((noinline))
clobber_lots_of_regs (void)
{
#define X1(n) long r##n = 10##n; __asm __volatile ("" : "+r" (r##n));
#define X2(n) X1(n##0) X1(n##1) X1(n##2) X1(n##3) X1(n##4)
#define X3(n) X2(n##0) X2(n##1) X2(n##2) X2(n##3) X2(n##4)
  X3(0) X3(1) X3(2) X3(3) X3(4)
#undef X1
#define X1(n) __asm __volatile ("" : : "r" (r##n));
  X3(0) X3(1) X3(2) X3(3) X3(4)
#undef X1
#undef X2
#undef X3
}

static int
do_test (void)
{
  pthread_t th;
  int old, rc;
  int ret = 0;
  int fd[2];
Exemplo n.º 2
0
void dooptab()
{       int i;
        FILE *f;

        /* Load optab[] */
#define X1(arr,mask) for(i=0;i<sizeof(arr)/sizeof(int);i++)xptab1[arr[i]]|=mask;
#define X2(arr,mask) for(i=0;i<sizeof(arr)/sizeof(int);i++)xptab2[arr[i]]|=mask;
#define X3(arr,mask) for(i=0;i<sizeof(arr)/sizeof(int);i++)xptab3[arr[i]]|=mask;

        X1(_binary,_OTbinary);
        X1(_unary,_OTunary);
        X1(_commut,_OTcommut);
        X1(_assoc,_OTassoc);
        X1(_sideff,_OTsideff);
        X1(_eop0e,_OTeop0e);
        X1(_eop00,_OTeop00);
        X1(_eop1e,_OTeop1e);

        X2(_logical,_OTlogical);
        X2(_wid,_OTwid);
        X2(_call,_OTcall);
        X2(_rtol,_OTrtol);
        X2(_assign,_OTassign);
        X2(_def,_OTdef);
        X2(_ae,_OTae);
        X2(_exp,_OTexp);

        X3(_boolnop,_OTboolnop);

#undef X3
#undef X2
#undef X1

        f = fopen("optab.c","w");
        fprintf(f,"const unsigned char optab1[OPMAX] =\n\t{");
        for (i = 0; i < OPMAX; i++)
        {       if ((i & 7) == 0)
                        fprintf(f,"\n\t");
                fprintf(f,"0x%x",xptab1[i]);
                if (i != OPMAX - 1)
                        fprintf(f,",");
        }
        fprintf(f,"\t};\n");
        fprintf(f,"const unsigned char optab2[OPMAX] =\n\t{");
        for (i = 0; i < OPMAX; i++)
        {       if ((i & 7) == 0)
                        fprintf(f,"\n\t");
                fprintf(f,"0x%x",xptab2[i]);
                if (i != OPMAX - 1)
                        fprintf(f,",");
        }
        fprintf(f,"\t};\n");
        fprintf(f,"const unsigned char optab3[OPMAX] =\n\t{");
        for (i = 0; i < OPMAX; i++)
        {       if ((i & 7) == 0)
                        fprintf(f,"\n\t");
                fprintf(f,"0x%x",xptab3[i]);
                if (i != OPMAX - 1)
                        fprintf(f,",");
        }
        fprintf(f,"\t};\n");

        fprintf(f,"const unsigned char opcost[OPMAX] =\n\t{");
        for (i = 0; i < OPMAX; i++)
        {       if ((i & 7) == 0)
                        fprintf(f,"\n\t");
                fprintf(f,"0x%x",cost(i));
                if (i != OPMAX - 1)
                        fprintf(f,",");
        }
        fprintf(f,"\t};\n");

        doreltables(f);
        fclose(f);
}
Exemplo n.º 3
0
static int sort(struct env *env, int M)
{
    int sp=0;
    struct tree *left=NULL, *right=NULL;
    int nBucket = 0;

    struct particle **ps = env->p;
    struct tree *node = env->tree;

    /*========================================================================
     * Allocate stack
     *======================================================================*/
    int ns = (int)MMAX(1, floor(log(((double)(env->N+1))/(M+1))/log(2.0)));
    sp = 0;
    sortStack = (struct tree **)realloc(sortStack, ns * sizeof(struct tree *));
    assert(sortStack != NULL);

    if (node->iUpper - node->iLower + 1 <= M) 
        return 0;

    while (1)
    {
        int i, p, k;
        struct particle *t;
        int nl, nr;
        int d;
        real fSplit;

        assert(node != NULL);
        split(node, &d, &fSplit);

#if 0
        i = node->iLower;
        int j = node->iUpper;

        //partitionCount++;
        //PARTITION(ps, t, ->r[d], i,j, < fSplit,> fSplit);
    	while (i <= j && ((ps[i] ->r[d]) < fSplit)) { ++i; } 

#if 0
        while (i <= j)
        {
            switch ((i-j) & 0x7)
                case 7: if 

        }
#endif


    	while (i <= j && ((ps[j] ->r[d]) > fSplit)) { --j; } 
    	while (i < j) { 
            SWAP(ps[i], ps[j], t); 
            while ((ps[++i] ->r[d]) < fSplit) { } 
            while ((ps[--j] ->r[d]) > fSplit) { } 
    	}

#else

#       define PART(A, i, j, t, d, CMPL) \
        do { \
            int k = i--; \
            do { \
                if (A[k]->r[d] CMPL) { i++; SWAP(A[i], A[k], t); } \
            } while (++k <= j); \
            i++; \
        } while(0)

        i = node->iLower;
        const int j = node->iUpper;

        switch (d)
        {
            case 0: PART(ps, i, j, t, 0, < fSplit); break;
            case 1: PART(ps, i, j, t, 1, < fSplit); break;
            case 2: PART(ps, i, j, t, 2, < fSplit); break;
        }
#endif

        //fprintf(err, "(%i %i)\n", i, node->iUpper);

        nl = i - node->iLower;
        nr = node->iUpper - i + 1;

        //fprintf(err, "nl=%i nr=%i\n", nl, nr);

        /*========================================================================
         * If both sides of the partition are not empty then create two new nodes
         * and crop the bounding boxes. Otherwise, undo the split operation.
         *======================================================================*/
        if (nl > 0 || nr > 0) {  // jpc changed this from && to || so that a split is always created.
            NEW_NODE(node, left, node->iLower, i - 1);
            NEW_NODE(node, right, i, node->iUpper);
            nodeCount += 2;

            X3( node->left->bnd.r   [_] = node->bnd.r   [_] );
            X3( node->left->bnd.max [_] = node->bnd.max [_] );

            node->left->bnd.max[d]          *= 0.5;
            node->left->bnd.r[d]            -= node->left->bnd.max[d];
            left = node->left;

            X3( node->right->bnd.r   [_] = node->bnd.r   [_] );
            X3( node->right->bnd.max [_] = node->bnd.max [_] );

            node->right->bnd.max[d]         *= 0.5;
            node->right->bnd.r[d]           += node->right->bnd.max[d];

            right = node->right;
        }
        else
        {
            node->bnd.max[d] *= 0.5;
            if (nl > 0) {
                node->bnd.r[d] -= node->bnd.max[d];
                left = node;
            }
            else {
                node->bnd.r[d] += node->bnd.max[d];
                right = node;
            }
        }

        /*========================================================================
         * Now figure out which subfile to process next
         *======================================================================*/
        if (nl > M && nr > M) 
        {
            if (nr > nl) sortStack[sp++] = right, node = left;
            else         sortStack[sp++] = left,  node = right;
        }
        else 
        {
            if (nl > M) node = left;
            //else if (nl > 0) left->iLower = 0;

            if (nr > M) node = right;
            //else if (nr > 0) right->iLower = 0;
        }

        if (nl <= M && nr <= M) {
            if (sp) node = sortStack[--sp];      /* pop tn */
            else break;
        }

    }

    return 0;
}
void test() {
  g1(X1());
  g2(X2());
  g3(X3());
  g4(X4<int>());
}
Exemplo n.º 5
0
Arquivo: enum29.C Projeto: 0day-ci/gcc
struct X4
{
  constexpr operator double() const { return 1.0; }
};

struct X5
{
  constexpr operator int() const { return __INT_MAX__; }
  constexpr operator unsigned() const { return __INT_MAX__ * 2U + 1; }
};

enum E0 { e0 = X0() };
enum E1 { e1 = X1() };
enum E2 { e2 = X2() };
enum E3 { e3 = X3() };
enum E4 { e4 = X4() };  // { dg-error "integer constant" }
enum E5 { e5 = X5() };  // { dg-error "ambiguous" }

enum F0 : int { f0 = X0() };
enum F1 : int { f1 = X1() };
enum F2 : int { f2 = X2() };
enum F3 : int { f3 = X3() };
enum F4 : int { f4 = X4() };  // { dg-error "narrowing" }
enum F5 : int { f5 = X5() };

enum G0 : signed char { g0 = X0() };
enum G1 : signed char { g1 = X1() };
enum G2 : signed char { g2 = X2() };  // { dg-error "narrowing" }
enum G3 : signed char { g3 = X3() };  // { dg-error "narrowing" }
enum G4 : signed char { g4 = X4() };  // { dg-error "narrowing" }
Exemplo n.º 6
0
bool
test_fundamentals(Index const dimension)
{
  bool
  passed = true;

  Index const
  number_components = integer_power(dimension, Tensor::ORDER);

  std::vector<Scalar> const
  X = generate_sequence<Scalar>(number_components, 1.0, 1.0);

  // Test constructor with pointer
  Tensor const
  A(dimension, &X[0]);

  // Test copy constructor
  Tensor
  B = A;

  Tensor
  C;

  // Test copy assignment
  C = B - A;

  Scalar
  error = norm_f(C);

  bool const
  copy_assigned = error <= machine_epsilon<Scalar>();
  passed = passed && copy_assigned;

  // Test fill with pointer
  B.fill(&X[0]);

  C = B - A;

  error = norm_f(C);

  bool const
  filled_pointer = error <= machine_epsilon<Scalar>();
  passed = passed && filled_pointer;

  std::vector<Scalar> const
  Y = generate_sequence<Scalar>(number_components, -1.0, -1.0);

  C.fill(&Y[0]);

  // Test increment
  C += A;

  error = norm_f(C);

  bool const
  incremented = error <= machine_epsilon<Scalar>();
  passed = passed && incremented;

  C.fill(&X[0]);

  // Test decrement
  C -= A;

  error = norm_f(C);

  bool const
  decremented = error <= machine_epsilon<Scalar>();
  passed = passed && decremented;

#ifdef HAVE_INTREPID_KOKKOSCORE
  //test Tensor fill and create for Kokkos data types
  Kokkos::View<Scalar *, Kokkos::DefaultExecutionSpace>
  X1("X1_kokkos", dimension);

  Kokkos::View<Scalar **, Kokkos::DefaultExecutionSpace>
  X2("X2_kokkos", dimension, dimension);

  Kokkos::View<Scalar ***, Kokkos::DefaultExecutionSpace>
  X3("X3_kokkos", dimension, dimension, dimension);

  Kokkos::View<Scalar ****, Kokkos::DefaultExecutionSpace>
  X4("X4_kokkos", dimension, dimension, dimension, dimension);

  Kokkos::deep_copy(X1, 3.1);
  Kokkos::deep_copy(X2, 3.2);
  Kokkos::deep_copy(X3, 3.3);
  Kokkos::deep_copy(X4, 3.4);

  Tensor
  Z(dimension); //(X1_k,0);

  Index
  rank = 0;

  Index
  temp = number_components;

  while (temp != 1) {
    temp = temp / dimension;
    rank = rank + 1;
    assert(temp > 0);
  }

  switch (rank) {
  default:
    assert(false);
    break;

  case 1:
    Z.fill(X1, 0);
    break;

  case 2:
    Z.fill(X2, 0, 0);
    break;

  case 3:
    Z.fill(X3, 0, 0, 0);
    break;

  case 4:
    Z.fill(X4, 0, 0, 0, 0);
    break;
  }

  // Test copy constructor.
  Tensor const
  U = Z;

  // Test copy assignment.
  Tensor
  V;

  V = U - Z;

  error = norm_f(V);

  bool const
  tensor_create_from_1d_kokkos = error <= machine_epsilon<Scalar>();
  passed = passed && tensor_create_from_1d_kokkos;
#endif 

  return passed;
}