StaticModelLoader::StaticModelLoader(char* path, char *mpath)
{
	m_infile.open(mpath);
	if (!m_infile) {
		cout << "Cannot open material file!\n";
		throw 1;
	}

	infile.open(path); //"res/car.obj"
	if (!infile) {
		cout << "Cannot open file!\n";
		throw 1;
	}

	mload();

	vload();

	infile.clear();
	infile.seekg(0, ios::beg);

	fload();

	infile.close();
	m_infile.close();

	//debug models
	std::cout << " verticies " << v_num
		<< " textures " << vt_num
		<< " normals " << vn_num
		<< " polygones " << f_num
		<< std::endl;
}
Exemplo n.º 2
0
void repl_driver(void)
{
    int k;
    k = setjmp(errjmp);
    if (k == 2) return;
    signal(SIGFPE,handle_sigfpe);
    signal(SIGINT,handle_sigint);
    close_open_files();
    errjmp_ok = 1;
    nointerrupt = 0;
    if (init_file && (k == 0)) vload(init_file);
    repl();
}
  std::string generate_impl(std::string const & kernel_prefix, statements_container const & statements, std::vector<mapping_type> const & mappings, unsigned int simd_width) const
  {
    std::string process_str;
    utils::kernel_generation_stream stream;

    std::string init0, upper_bound0, inc0, init1, upper_bound1, inc1;

    stream << " __attribute__((reqd_work_group_size(" << p_.local_size_0 << "," << p_.local_size_1 << ",1)))" << std::endl;
    generate_prototype(stream, kernel_prefix, "unsigned int M, unsigned int N,", mappings, statements);
    stream << "{" << std::endl;
    stream.inc_tab();

    tree_parsing::process(stream, PARENT_NODE_TYPE, "scalar", "#scalartype #namereg = *#pointer;", statements, mappings);
    tree_parsing::process(stream, PARENT_NODE_TYPE, "matrix", "#pointer += $OFFSET{#start1, #start2};", statements, mappings);
    tree_parsing::process(stream, PARENT_NODE_TYPE, "vector", "#pointer += #start;", statements, mappings);

    fetching_loop_info(p_.fetching_policy, "M", stream, init0, upper_bound0, inc0, "get_global_id(0)", "get_global_size(0)");
    stream << "for(unsigned int i = " << init0 << "; i < " << upper_bound0 << "; i += " << inc0 << ")" << std::endl;
    stream << "{" << std::endl;
    stream.inc_tab();
    fetching_loop_info(p_.fetching_policy, "N", stream, init1, upper_bound1, inc1, "get_global_id(1)", "get_global_size(1)");
    stream << "for(unsigned int j = " << init1 << "; j < " << upper_bound1 << "; j += " << inc1 << ")" << std::endl;
    stream << "{" << std::endl;
    stream.inc_tab();

    process_str = utils::append_width("#scalartype",simd_width) + " #namereg = " + vload(simd_width, "$OFFSET{i*#stride1,j*#stride2}", "#pointer")+ ";";
    tree_parsing::process(stream, PARENT_NODE_TYPE, "matrix", process_str, statements, mappings);
    tree_parsing::process(stream, PARENT_NODE_TYPE, "vector_diag", "#scalartype #namereg = ((i + ((#diag_offset<0)?#diag_offset:0))!=(j-((#diag_offset>0)?#diag_offset:0)))?0:#pointer[min(i*#stride, j*#stride)];", statements, mappings);


    std::map<std::string, std::string> accessors;
    accessors["matrix"] = "#namereg";
    accessors["vector_diag"] = "#namereg";
    accessors["scalar"] = "#namereg";
    tree_parsing::evaluate(stream, PARENT_NODE_TYPE, accessors, statements, mappings);

    process_str = vstore(simd_width, "#namereg", "$OFFSET{i*#stride1,j*#stride2}", "#pointer")+";";
    tree_parsing::process(stream, LHS_NODE_TYPE, "matrix", process_str, statements, mappings);

    stream.dec_tab();
    stream << "}" << std::endl;
    stream.dec_tab();
    stream << "}" << std::endl;

    stream.dec_tab();
    stream << "}" << std::endl;

    return stream.str();
  }
Exemplo n.º 4
0
void getcol(int c, double* x, double** bb, int nth)
{
	int ii = c/BL;
	int r = c%BL;
	int id = ii%nth;
#if TILE_SCHEME == 0
	int mynbl = (ii-id+nth-1)/nth;
	size_t t = mynbl*((2*id+2+nth*(mynbl-1))/2)*BL*BL;
#else
	size_t t = 0;
	for(int I=id, i=id*BL; I<ii; I+=nth, i+=nth*BL)
		t += (i+BL+RJ-1)/RJ*RJ*BL;
#endif
	double* b = bb[id] + t + r*RJ;
	for(int j=0; j<=c; j+=RJ){
		vstore(x, vload(b));
		x += RJ;
		b += RJ*BL;
	}
}
Exemplo n.º 5
0
 *
 *  Copyright (C) 2012-2017 Max-Planck-Society
 *  \author Martin Reinecke
 */

NOINLINE static void Z(alm2map_kernel) (const Tb cth, Y(Tbri) * restrict p1,
  Y(Tbri) * restrict p2, Tb lam_1, Tb lam_2,
  const sharp_ylmgen_dbl2 * restrict rf, const dcmplx * restrict alm,
  int l, int lmax NJ1)
  {
if (njobs>1)
  {
  while (l<lmax-2)
    {
    Tb lam_3, lam_4;
    Tv r0=vload(rf[l].f[0]),r1=vload(rf[l].f[1]);
    for (int i=0; i<nvec; ++i)
      lam_3.v[i] = vsub(vmul(vmul(cth.v[i],lam_2.v[i]),r0),vmul(lam_1.v[i],r1));
    r0=vload(rf[l+1].f[0]);r1=vload(rf[l+1].f[1]);
    for (int i=0; i<nvec; ++i)
      lam_4.v[i] = vsub(vmul(vmul(cth.v[i],lam_3.v[i]),r0),vmul(lam_2.v[i],r1));
    r0=vload(rf[l+2].f[0]);r1=vload(rf[l+2].f[1]);
    for (int i=0; i<nvec; ++i)
      lam_1.v[i] = vsub(vmul(vmul(cth.v[i],lam_4.v[i]),r0),vmul(lam_3.v[i],r1));
    for (int j=0; j<njobs; ++j)
      {
      Tv ar2=vload(creal(alm[njobs*l+j])),
         ai2=vload(cimag(alm[njobs*l+j])),
         ar4=vload(creal(alm[njobs*(l+2)+j])),
         ai4=vload(cimag(alm[njobs*(l+2)+j]));
      for (int i=0; i<nvec; ++i)
f128tuple histohit(f128tuple xyvec, const colorset pointcolors[4], const i32 th_id){
    // don't plot the first 20 iterations
    if(threadHits[th_id]++ > 20){
        f128 xarr = xyvec.x;
        f128 yarr = xyvec.y;

        // check to see if any points have escaped to infinity or are NaN
        // if they have, reset them and the threadHits counter to 0
        if(vvalid(xarr.v) && vvalid(yarr.v)){

            // scale the points from fractal-space to histogram-space
            f128 scaledX;
            scaledX.v = vadd(
                           vmul(
                               vadd(xarr.v, xoffsetvec),
                               hwidShrunkvec),
                           halfhwidvec);
            f128 scaledY;
            scaledY.v = vadd(
                            vmul(
                                vadd(yarr.v, yoffsetvec),
                                hheiShrunkvec),
                            halfhheivec);
            
            // extract each point and plot
            for (i32 i = 0; i < FLOATS_PER_VECTOR_REGISTER; i++){
                const u32 ix = scaledX.f[i];
                const u32 iy = scaledY.f[i];

                if(ix < hwid && iy < hhei){
                    const u64 cell = ix + (iy * hwid);
                    // lock the row
                    omp_set_lock(&(locks[iy]));
                    
                    // load the existing data
                    // the cache miss here takes up maybe 2/3s of the program's execution time
                    __m128 histocolor = vload((float *)&(h[cell]));
                    
                    // add the new color to the old
                    histocolor = vadd(
                                    histocolor,
                                    pointcolors[i].vec);

                    // write back
                    vstore((float *)&(h[cell]), histocolor);

                    ++goodHits;

                    // unlock the cell
                    omp_unset_lock(&(locks[iy]));
                } else {
                    ++missHits;
                }
            }
        } else {
            ++badHits;
            threadHits[th_id] = 0;
            xyvec.x = zerovec;
            xyvec.y = zerovec;
        }
    }
    return xyvec;
}