コード例 #1
0
ファイル: tutorial11_device.cpp プロジェクト: davenso/embree
void build_sah(vector_t<PrimRef>& prims, isa::PrimInfo& pinfo)
{
  size_t N = pinfo.size();

  /* fast allocator that supports thread local operation */
  FastAllocator allocator;

  for (size_t i=0; i<2; i++)
  {
    std::cout << "iteration " << i << ": building BVH over " << N << " primitives, " << std::flush;
    double t0 = getSeconds();
    
    allocator.reset();

    Node* root;
    isa::BVHBuilderBinnedSAH::build<Node*>(
      root,
      /* thread local allocator for fast allocations */
      [&] () -> FastAllocator::ThreadLocal* { 
        return allocator.threadLocal(); 
      },

      /* lambda function that creates BVH nodes */
      [&](const isa::BVHBuilderBinnedSAH::BuildRecord& current, isa::BVHBuilderBinnedSAH::BuildRecord* children, const size_t N, FastAllocator::ThreadLocal* alloc) -> int
      {
        assert(N <= 2);
        InnerNode* node = new (alloc->malloc(sizeof(InnerNode))) InnerNode;
        for (size_t i=0; i<N; i++) {
          node->bounds[i] = children[i].pinfo.geomBounds;
          children[i].parent = (size_t*) &node->children[i];
        }
        *current.parent = (size_t) node;
	return 0;
      },

      /* lambda function that creates BVH leaves */
      [&](const isa::BVHBuilderBinnedSAH::BuildRecord& current, FastAllocator::ThreadLocal* alloc) -> int
      {
        assert(current.prims.size() == 1);
        Node* node = new (alloc->malloc(sizeof(LeafNode))) LeafNode(prims[current.prims.begin()].ID(),prims[current.prims.begin()].bounds());
        *current.parent = (size_t) node;
	return 0;
      },

      /* progress monitor function */
      [&] (size_t dn) { 
        // throw an exception here to cancel the build operation
      },

      prims.data(),pinfo,2,1024,1,1,1,1.0f,1.0f);
    
    double t1 = getSeconds();

    std::cout << 1000.0f*(t1-t0) << "ms, " << 1E-6*double(N)/(t1-t0) << " Mprims/s, sah = " << root->sah() << " [DONE]" << std::endl;
  }
}
コード例 #2
0
ファイル: test_affine.cpp プロジェクト: accosmin/nano
 scalar_t vgrad(const vector_t& x, vector_t* gx) const override
 {
         m_idata = map_tensor(x.data(), m_idata.dims());
         m_op.output(m_idata, m_wdata, m_bdata, m_odata);
         if (gx)
         {
                 gx->resize(x.size());
                 auto idata = map_tensor(gx->data(), m_idata.dims());
                 m_op.ginput(idata, m_wdata, m_bdata, m_odata);
         }
         return m_odata.array().square().sum() / 2;
 }
コード例 #3
0
ファイル: test_affine.cpp プロジェクト: accosmin/nano
 scalar_t vgrad(const vector_t& x, vector_t* gx) const override
 {
         m_wdata = map_matrix(x.data(), m_wdata.rows(), m_wdata.cols());
         m_bdata = map_vector(x.data() + m_wdata.size(), m_bdata.size());
         m_op.output(m_idata, m_wdata, m_bdata, m_odata);
         if (gx)
         {
                 gx->resize(x.size());
                 auto wdata = map_matrix(gx->data(), m_wdata.rows(), m_wdata.cols());
                 auto bdata = map_vector(gx->data() + m_wdata.size(), m_bdata.size());
                 m_op.gparam(m_idata, wdata, bdata, m_odata);
         }
         return m_odata.array().square().sum() / 2;
 }
コード例 #4
0
ファイル: uLAPACK.hpp プロジェクト: GangDesign/open_ptrack
// QR Factorization of a MxN General Matrix A.
//    a       (IN/OUT - matrix(M,N)) On entry, the coefficient matrix A. On exit , the upper triangle and diagonal is the min(M,N) by N upper triangular matrix R.  The lower triangle, together with the tau vector, is the orthogonal matrix Q as a product of min(M,N) elementary reflectors.
//    tau     (OUT - vector (min(M,N))) Vector of the same numerical type as A. The scalar factors of the elementary reflectors.
//    info    (OUT - int)
//   0   : function completed normally
//   < 0 : The ith argument, where i = abs(return value) had an illegal value.
int geqrf (matrix_t& a, vector_t& tau)
{
	int              _m = int(a.size1());
	int              _n = int(a.size2());
	int              _lda = int(a.size1());
	int              _info;

	// make_sure tau's size is greater than or equal to min(m,n)
	if (int(tau.size()) < (_n<_m ? _n : _m) )
		return -104;

	int ldwork = _n*_n;
	vector_t dwork(ldwork);
	rawLAPACK::geqrf (_m, _n, a.data().begin(), _lda, tau.data().begin(), dwork.data().begin(), ldwork, _info);

	return _info;
}
コード例 #5
0
ファイル: eigen_util.cpp プロジェクト: cmu-db/peloton
vector_eig EigenUtil::ToEigenVec(const vector_t &mat) {
  return vector_eig::Map(mat.data(), mat.size());
}