Пример #1
0
int benchNoCachingNoVector(Vector3D<Precision> const &point, Vector3D<Precision> const &dir,
                           std::vector<Vector3D<Precision>> const &corners
#ifdef SORTHITBOXES
                           ,
                           Container_t &hitlist
#endif
                           )
{
#ifdef INNERTIMER
  Stopwatch timer;
  timer.Start();
#endif
  int vecsize  = corners.size() / 2;
  int hitcount = 0;
  for (auto box = 0; box < vecsize; ++box) {
    double distance = BoxImplementation<translation::kIdentity, rotation::kIdentity>::Intersect(
        &corners[2 * box], point, dir, 0, vecgeom::kInfLength);
    if (distance < vecgeom::kInfLength) {
      hitcount++;
#ifdef SORTHITBOXES
      hitlist.push_back(BoxIdDistancePair_t(box, distance));
#endif
    }
  }
#ifdef INNERTIMER
  timer.Stop();
  std::cerr << "# ORDINARY hitting " << hitcount << "\n";
  std::cerr << "# ORDINARY timer " << timer.Elapsed() << "\n";
#endif
  return hitcount;
}
Пример #2
0
int benchCachingAndVector(Vector3D<Precision> const &point, Vector3D<Precision> const &dir,
                          Vector3D<kVc::precision_v> const *corners, int vecsize
#ifdef SORTHITBOXES
                          ,
                          Container_t &hitlist
#endif
                          )
{
#ifdef INNERTIMER
  Stopwatch timer;
  timer.Start();
#endif

  Vector3D<Precision> invdir(1. / dir.x(), 1. / dir.y(), 1. / dir.z());
  int hitcount = 0;

  int sign[3];
  sign[0] = invdir.x() < 0;
  sign[1] = invdir.y() < 0;
  sign[2] = invdir.z() < 0;
  for (auto box = 0; box < vecsize; ++box) {
    kVc::precision_v distance =
        BoxImplementation<translation::kIdentity, rotation::kIdentity>::IntersectCachedKernel2<kVc>(
            &corners[2 * box], point, invdir, sign[0], sign[1], sign[2], 0, vecgeom::kInfLength);
    kVc::bool_v hit = distance < vecgeom::kInfLength;
    // std::cerr << hit << "\n";
    // this is Vc specific
    hitcount += hit.count();
#ifdef SORTHITBOXES
    // a little tricky: need to iterate over the mask
    for (auto i = 0; i < kVc::precision_v::Size; ++i) {
      if (hit[i])
        // which box id??
        hitlist.push_back(BoxIdDistancePair_t(box * kVc::precision_v::Size + i, distance[i]));
    }
#endif
  }
// interpret as binary number and do a switch statement
// do a big switch statement here
//    switch( size[0] + size[1] + size[2] ){
//    case 0: {
//        for( auto box = 0; box < vecsize; ++box ){
//        kVc::precision_v distance = BoxImplementation<translation::kIdentity,
//        rotation::kIdentity>::IntersectCachedKernel<kVc,0,0,0>(
//           &corners[2*box],
//           point,
//           invdir,
//           0, vecgeom::kInfLength );
//           kVc::bool_v hit = distance < vecgeom::kInfLength;
//           //std::cerr << hit << "\n";
//           hitcount += hit.count();
//        }       break; }
//    case 3: {
//        for( auto box = 0; box < vecsize; ++box ){
//          kVc::precision_v distance = BoxImplementation<translation::kIdentity,
//          rotation::kIdentity>::IntersectCachedKernel<kVc,1,1,1>(
//          &corners[2*box],
//          point,
//          invdir,
//          0, vecgeom::kInfLength );
//          kVc::bool_v hit = distance < vecgeom::kInfLength;
//          //std::cerr << hit << "\n";
//          hitcount += hit.count();
//    }       break; }
//    default : std::cerr << "DEFAULT CALLED\n";
//    }
#ifdef INNERTIMER
  timer.Stop();
  std::cerr << "# VECTOR hitting " << hitcount << "\n";
  std::cerr << "# VECTOR timer " << timer.Elapsed() << "\n";
#endif
  return hitcount;
}
Пример #3
0
int benchCachingNoVector(Vector3D<Precision> const &point, Vector3D<Precision> const &dir,
                         std::vector<Vector3D<Precision>> const &corners
#ifdef SORTHITBOXES
                         ,
                         Container_t &hitlist
#endif
                         )
{
#ifdef INNERTIMER
  Stopwatch timer;
  timer.Start();
#endif

  Vector3D<Precision> invdir(1. / dir.x(), 1. / dir.y(), 1. / dir.z());
  int vecsize  = corners.size() / 2;
  int hitcount = 0;
  int sign[3];
  sign[0] = invdir.x() < 0;
  sign[1] = invdir.y() < 0;
  sign[2] = invdir.z() < 0;
  // interpret as binary number and do a switch statement
  // do a big switch statement here
  // int code = 2 << size[0] + 2 << size[1] + 2 << size[2];
  for (auto box = 0; box < vecsize; ++box) {
    double distance = BoxImplementation<translation::kIdentity, rotation::kIdentity>::IntersectCachedKernel2<kScalar>(
        &corners[2 * box], point, invdir, sign[0], sign[1], sign[2], 0, vecgeom::kInfLength);
    if (distance < vecgeom::kInfLength) {
      hitcount++;
#ifdef SORTHITBOXES
      hitlist.push_back(BoxIdDistancePair_t(box, distance));
#endif
    }
  }

//    switch( size[0] + size[1] + size[2] ){
//    case 0: {
//        for( auto box = 0; box < vecsize; ++box ){
//        double distance = BoxImplementation<translation::kIdentity,
//        rotation::kIdentity>::IntersectCachedKernel<kScalar,0,0,0>(
//           &corners[2*box],
//           point,
//           invdir,
//           0, vecgeom::kInfLength );
//           if( distance < vecgeom::kInfLength ) hitcount++;
//         }       break; }
//    case 3: {
//        for( auto box = 0; box < vecsize; ++box ){
//                double distance = BoxImplementation<translation::kIdentity,
//                rotation::kIdentity>::IntersectCachedKernel<kScalar,1,1,1>(
//                   &corners[2*box],
//                   point,
//                   invdir,
//                   0, vecgeom::kInfLength );
//                   if( distance < vecgeom::kInfLength ) hitcount++;
//                 }       break; }
//    default : std::cerr << "DEFAULT CALLED\n";
//    }
#ifdef INNERTIMER
  timer.Stop();
  std::cerr << "# CACHED hitting " << hitcount << "\n";
  std::cerr << "# CACHED timer " << timer.Elapsed() << "\n";
#endif
  return hitcount;
}