int main (int argc, char* argv[])
   {
  // Main Function for default example ROSE Preprocessor
  // This is an example of a preprocessor that can be built with ROSE

  // Build the project object (AST) which we will fill up with multiple files and use as a
  // handle for all processing of the AST(s) associated with one or more source files.
     SgProject* sageProject = frontend(argc,argv);

  // DQ (7/20/2004): Added internal consistancy tests on AST
     AstTests::runAllTests(sageProject);

  // This is not needed here
  // FixSgProject(sageProject);

     bool changed = true;
     int  count   = 0;

  /* Inline one call at a time until all have been inlined.  Loops on recursive code. */
     while (changed)
        {
          changed = false;
          calls_to_inline.clear();
          FindCallsVisitor().traverseInputFiles(sageProject, preorder);

          for (std::vector<SgFunctionCallExp*>::iterator i = calls_to_inline.begin(); i != calls_to_inline.end(); ++i)
             {
            // cout << (*i)->unparseToString() << endl;
            // generateAstGraph(sageProject, 400000);
               if (doInline(*i))
                  {
                    changed = true;
                 // AstTests::runAllTests(sageProject);
                    break;
                  }
             }
          ++count;
#if 0
          sageProject.unparse();
#endif
       // To prevent infinite loops
          if (count == 10)
             {
               break;
             }
        }

#if 1

  // Rename each variable declaration
     renameVariables(sageProject);

#if 1
  // Fold up blocks
     flattenBlocks(sageProject);

  // Clean up inliner-generated code
     cleanupInlinedCode(sageProject);
#endif

  // Change members to public
     changeAllMembersToPublic(sageProject);

  // AstPDFGeneration().generateInputFiles(sageProject);
  // AstDOTGeneration().generateInputFiles(sageProject);
#endif

     AstTests::runAllTests(sageProject);

#if 0
  // Output an optional graph of the AST (just the tree, when active)
     printf ("Generating a dot file... (ROSE Release Note: turn off output of dot files before committing code) \n");
     generateDOT (*sageProject );
     // generateAstGraph(project, 2000);
#endif

#if 1
  // Output an optional graph of the AST (the whole graph, of bounded complexity, when active)
     const int MAX_NUMBER_OF_IR_NODES_TO_GRAPH_FOR_WHOLE_GRAPH = 8000;
     generateAstGraph(sageProject,MAX_NUMBER_OF_IR_NODES_TO_GRAPH_FOR_WHOLE_GRAPH);
#endif


     return backend(sageProject);
   }
Beispiel #2
0
 /**
  * @brief Checks if a specific tag exists in the block.
  *
  * @param name_or_id        Name or id of a tag.
  *
  * @return True if the tag exists, false otherwise.
  */
 bool hasTag(const std::string &name_or_id) const {
     return backend()->hasTag(name_or_id);
 }
Beispiel #3
0
 /**
  * @brief Returns the number of tags within this block.
  *
  * @return The number of tags.
  */
 ndsize_t tagCount() const {
     return backend()->tagCount();
 }
Beispiel #4
0
void Database::reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
{
    backend()->reportCommitTransactionResult(errorSite, webSqlErrorCode, sqliteErrorCode);
}
Beispiel #5
0
X11Output::~X11Output()
{
	if(eglSurface_)backend().eglContext()->destroySurface(eglSurface_);
    xcb_destroy_window(backend().xConnection(), xWindow_);
}
Beispiel #6
0
 bool valid() const
 { return backend().valid(m_handle); }
Beispiel #7
0
void Feature::data(const std::string &name_or_id) {
    util::checkNameOrId(name_or_id);
    backend()->data(name_or_id);
}
Beispiel #8
0
 /**
  * @brief Deletes all values from the property.
  */
 void deleteValues() {
     backend()->deleteValues();
 }
Beispiel #9
0
 /**
  * @brief Get the number of values of the property.
  *
  * @return The number of values.
  */
 ndsize_t valueCount() const {
     return backend()->valueCount();
 }
Beispiel #10
0
 /**
  * @brief Returns the unit for all stored values.
  *
  * @return The unit for all values.
  */
 boost::optional<std::string> unit() const {
     return backend()->unit();
 }
Beispiel #11
0
 /**
  * @brief Remove the unit.
  *
  * @param t         None
  */
 void unit(const boost::none_t t) {
     return backend()->unit(t);
 }
Beispiel #12
0
 /**
  * @brief Returns the data type of the stored Values.
  *
  * @return The data type.
  */
 DataType dataType() const {
     return backend()->dataType();
 }
Beispiel #13
0
 /**
  * @brief Deletes the mapping information.
  *
  * @param t         None
  */
 void mapping(const boost::none_t t) {
     backend()->mapping(t);
 }
Beispiel #14
0
 /**
  * @brief Getter for the mapping information stored in this Property.
  *
  * @return The mapping for the Property.
  */
 boost::optional<std::string> mapping() const {
     return backend()->mapping();
 }
Beispiel #15
0
 void bind()
 { assert(valid() && "Program is not valid"); backend().bind(m_handle); }
Beispiel #16
0
 /**
  * @brief Set the values of the property.
  *
  * @param values    The values to set.
  */
 void values(const std::vector<Value> &values) {
     backend()->values(values);
 }
Beispiel #17
0
 bool bound() const
 { return backend().bound(m_backend); }
Beispiel #18
0
 /**
  * @brief Get all values of the property.
  *
  * @return The values of the property.
  */
 std::vector<Value> values(void) const {
     return backend()->values();
 }
Beispiel #19
0
 uniform<T> uniform(const std::string& name) const
 { return uniform<T>{m_handle, backend().uniform_location(name)}; }
Beispiel #20
0
 /**
  * @brief Deletes all values from the property.
  */
 void values(const boost::none_t t) {
     backend()->values(t);
 }
Beispiel #21
0
Type & Type::toScalarType(ScalarType s) const {
  return context->getType(backend(),s);
}
Beispiel #22
0
int main(int argc, char *argv[]) {

	if (argc > 1 && argv[1][0] == 'b' && argv[1][1] == 'm') {
		mdct_type mdct;
		for(int i = 0; i < 1000000; ++i) 
			mdct.mdct();
		return 0;
	}
	if (argc > 1 && argv[1][0] == 'b' && argv[1][1] == 'f') {
		fft_type fft;
		for(int i = 0; i < 2000000; ++i) 
			fft.fft();
		return 0;
	}
	if (argc > 1 && argv[1][0] == 't') {
		fft_type fft;
		for(int i = 0; i < fft_type::N; ++i) {
			fft.data[i] = std::complex<float>((float)((i / 4) & 1), 0);
		}
		fft.fft();
		for(int i = 0; i < fft_type::N; ++i) {
			printf("%f, %f = %f\n", fft.data[i].real(), fft.data[i].imag(), std::abs(fft.data[i]));
		}
		fft.ifft();

		for(int i = 0; i < fft_type::N; ++i) {
			fft.data[i] -= std::complex<float>((float)((i / 4) & 1), 0);
			printf("%f, %f\n", fft.data[i].real(), fft.data[i].imag());
		}
		
		return 0;
	}
	if (argc > 1 && argv[1][0] == 'f')
	{
		printf("reference: \n");
		mdct_test<clunk::ref_mdct_context<3, clunk::sin_window_func, float> > test;
		test.feed();
		test.feed();
		test.feed();
		test.feed();
		printf("fft based: \n");
		mdct_test<clunk::mdct_context<3, clunk::sin_window_func, float> > test2;
		test2.feed();
		test2.feed();
		test2.feed();
		test2.feed();
		return 0;
	}

	clunk::sdl::Backend backend(44100, 2, 1024);
	clunk::Context &context = backend.get_context();
	
	clunk::Object * o = context.create_object();
	clunk::Sample * s = clunk::WavFile::load(context, "scissors.wav");
	clunk::Sample * h = clunk::WavFile::load(context, "helicopter.wav");

	static const int d = 3, n = 72;
	clunk::DistanceModel dm(clunk::DistanceModel::Exponent, false);
	dm.rolloff_factor = 0.7f;
	context.set_distance_model(dm);
	
	context.save("test_out.raw");
	backend.start();
/*	o->play("l", new clunk::Source(s, false, clunk::v3f(-d, 0, 0)));
	sleep(1);
	//o->play("c", new clunk::Source(s, false, clunk::v3f(0, 0, 0)));
	//sleep(1);
	o->play("r", new clunk::Source(s, false, clunk::v3f(d, 0, 0)));
	sleep(1);

	o->play("u", new clunk::Source(s, false, clunk::v3f(0, d, 0)));
	sleep(1);

	o->play("b", new clunk::Source(s, false, clunk::v3f(0, 0, d)));
	sleep(1);
*/
	o->play("h", new clunk::Source(h, true));

	for(int i = 0; i <= n; ++i) {
		float a = float(2 * M_PI * i / n);
		clunk::v3f pos(cos(a) * d, sin(a) * d * 2, 1);
		o->set_position(pos);
		printf("%g %g %g\n", pos.x, pos.y, pos.z);
		usleep(100000);
	}

/*	for(int i = 0; i <= n; ++i) {
		float a = M_PI * i / n;
		o->play("s", new clunk::Source(s, false, clunk::v3f(cos(a), -0.25f, sin(a)) * d));
		usleep(500000);
	}
*/	backend.stop();
	return 0;
}
Beispiel #23
0
int main (int argc, char *argv[])
{

    //  Prepare our context and sockets
    zmq::context_t context(1);
    zmq::socket_t frontend (context, ZMQ_XREP);
    zmq::socket_t backend (context, ZMQ_XREP);
    frontend.bind("ipc://frontend.ipc");
    backend.bind("ipc://backend.ipc");

    int client_nbr;
    for (client_nbr = 0; client_nbr < 10; client_nbr++) {
        pthread_t client;
        pthread_create (&client, NULL, client_thread, NULL);
    }
    int worker_nbr;
    for (worker_nbr = 0; worker_nbr < 3; worker_nbr++) {
        pthread_t worker;
        pthread_create (&worker, NULL, worker_thread, NULL);
    }
    //  Logic of LRU loop
    //  - Poll backend always, frontend only if 1+ worker ready
    //  - If worker replies, queue worker as ready and forward reply
    //    to client if necessary
    //  - If client requests, pop next worker and send request to it
    //
    //  A very simple queue structure with known max size
    std::queue<std::string> worker_queue;

    while (1) {
    	
        //  Initialize poll set
        zmq::pollitem_t items [] = {
            //  Always poll for worker activity on backend
            { backend,  0, ZMQ_POLLIN, 0 },
            //  Poll front-end only if we have available workers
            { frontend, 0, ZMQ_POLLIN, 0 }
        };
        if (worker_queue.size())
            zmq::poll (&items [0], 2, -1);
        else
            zmq::poll (&items [0], 1, -1);

        //  Handle worker activity on backend
        if (items [0].revents & ZMQ_POLLIN) {
        	
            //  Queue worker address for LRU routing
            worker_queue.push(s_recv (backend));

            {
               //  Second frame is empty
               std::string empty = s_recv (backend);
               assert (empty.size() == 0);
            }

            //  Third frame is READY or else a client reply address
            std::string client_addr = s_recv (backend);

            //  If client reply, send rest back to frontend
            if (client_addr.compare("READY") != 0) {
                
                {
                    std::string empty = s_recv (backend);
                    assert (empty.size() == 0);
                }
                
                std::string reply = s_recv (backend);
                s_sendmore (frontend, client_addr);
                s_sendmore (frontend, "");
                s_send     (frontend, reply);
                
                if (--client_nbr == 0)
                    break;
            }
        }
        if (items [1].revents & ZMQ_POLLIN) {
        	
            //  Now get next client request, route to LRU worker
            //  Client request is [address][empty][request]
            std::string client_addr = s_recv (frontend);
            
            {
                std::string empty = s_recv (frontend);
                assert (empty.size() == 0);
            }
            
            std::string request = s_recv (frontend);

            std::string worker_addr = worker_queue.front();//worker_queue [0];
            worker_queue.pop();

            s_sendmore (backend, worker_addr);
            s_sendmore (backend, "");
            s_sendmore (backend, client_addr);
            s_sendmore (backend, "");
            s_send     (backend, request);
        }
    }
    sleep (1);
    return 0;
}
Beispiel #24
0
 void attach(const shader& sh)
 { backend().attach_shader(m_handle, sh.type(), sh.handle()); } 
Beispiel #25
0
 /**
  * @brief Deletes a data array from this block.
  *
  * This deletes a data array and all its dimensions from the block and the file.
  * The deletion can't be undone.
  *
  * @param name_or_id        Name or id of the data array to delete.
  *
  * @return True if the data array was deleted, false otherwise.
  */
 bool deleteDataArray(const std::string &name_or_id) {
     return backend()->deleteDataArray(name_or_id);
 }
Beispiel #26
0
 bool link()
 { 
     return backend().link(m_handle); 
 }
Beispiel #27
0
 /**
  * @brief Retrieves a specific tag from the block by its id.
  *
  * @param name_or_id        Name or id of the tag.
  *
  * @return The tag with the specified id. If this tag doesn't exist
  *         an exception will be thrown.
  */
 Tag getTag(const std::string &name_or_id) const {
     return backend()->getTag(name_or_id);
 }
Beispiel #28
0
 /// \note Must be called before link
 void bind_attribute(std::size_t location, const std::string& name)
 {
     backend().bind_attribute(m_handle, location, name);
 }
Beispiel #29
0
 /**
  * @brief Deletes a tag from the block.
  *
  * Deletes a tag with all its features from the block and the file.
  * The deletion can't be undone.
  *
  * @param name_or_id        Name or id of the tag to remove.
  *
  * @return True if the tag was removed, false otherwise.
  */
 bool deleteTag(const std::string &name_or_id) {
     return backend()->deleteTag(name_or_id);
 }
void
ThermalBlockMinimalVersion::initModel()
{

    gamma_dir=option(_name="gamma_dir").template as<double>();

    this->setFunctionSpaces( Pch<1>( loadMesh( _mesh=new Mesh<Simplex<2>> ) ) );

    auto mesh = Xh->mesh();

    if( Environment::worldComm().isMasterRank() )
    {
        std::cout << "Number of local dof " << Xh->nLocalDof() << "\n";
        std::cout << "Number of dof " << Xh->nDof() << "\n";
    }

    auto mu_min = Dmu->element();
    auto mu_max = Dmu->element();
    mu_min <<  0.1 , 0.1 , 0.1 , 0.1 , 0.1 , 0.1 , 0.1 , 0.1 ;
    mu_max <<  10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 ;
    Dmu->setMin( mu_min );
    Dmu->setMax( mu_max );

    auto u = Xh->element();
    auto v = Xh->element();

    auto M = backend()->newMatrix( Xh , Xh );

    double mu_min_coeff=0.1;
    // on boundary north we have u=0 so term from weak dirichlet condition
    // vanish in the right hand side
    //rhs
    auto f0 = form1( _test=Xh );
    f0 =  integrate( _range=markedfaces( mesh,"south_domain-1" ), _expr= id( v ) )
        + integrate( _range=markedfaces( mesh,"south_domain-2" ), _expr= id( v ) )
        + integrate( _range=markedfaces( mesh,"south_domain-3" ), _expr= id( v ) );
    this->addRhs( { f0, "1" } );

    //lhs
    auto a0 = form2( _trial=Xh, _test=Xh);
    a0 = integrate( markedelements( mesh, "domain-1" ), gradt( u )*trans( grad( v ) ) );
    this->addLhs( { a0 , "1" } );
    auto a1 = form2( _trial=Xh, _test=Xh);
    a1 = integrate( markedelements( mesh, "domain-2" ), gradt( u )*trans( grad( v ) ) );
    this->addLhs( { a1 , "mu0" } );
    auto a2 = form2( _trial=Xh, _test=Xh);
    a2 = integrate( markedelements( mesh, "domain-3" ), gradt( u )*trans( grad( v ) ) );
    this->addLhs( { a2 , "mu1" } );
    auto a3 = form2( _trial=Xh, _test=Xh);
    a3 = integrate( markedelements( mesh, "domain-4" ), gradt( u )*trans( grad( v ) ) );
    this->addLhs( { a3 , "mu2" } );
    auto a4 = form2( _trial=Xh, _test=Xh);
    a4 = integrate( markedelements( mesh, "domain-5" ), gradt( u )*trans( grad( v ) ) );
    this->addLhs( { a4 , "mu3" } );
    auto a5 = form2( _trial=Xh, _test=Xh);
    a5 = integrate( markedelements( mesh, "domain-6" ), gradt( u )*trans( grad( v ) ) );
    this->addLhs( { a5 , "mu4" } );
    auto a6 = form2( _trial=Xh, _test=Xh);
    a6 = integrate( markedelements( mesh, "domain-7" ), gradt( u )*trans( grad( v ) ) )
        +integrate( markedfaces( mesh, "north_domain-7" ),
                   -gradt( u )*vf::N()*id( v )
                   -grad( u )*vf::N()*idt( v )
                   );
    this->addLhs( { a6 , "mu5" } );
    auto a7 = form2( _trial=Xh, _test=Xh);
    a7 = integrate( markedelements( mesh, "domain-8" ), gradt( u )*trans( grad( v ) ) )
        +integrate( markedfaces( mesh, "north_domain-8" ),
                   -gradt( u )*vf::N()*id( v )
                   -grad( u )*vf::N()*idt( v )
                   );
    this->addLhs( { a7 , "mu6" } );
    auto a8 = form2( _trial=Xh, _test=Xh);
    a8 = integrate( markedelements( mesh, "domain-9" ), gradt( u )*trans( grad( v ) ) )
        +integrate( markedfaces( mesh, "north_domain-9" ),
                   -gradt( u )*vf::N()*id( v )
                   -grad( u )*vf::N()*idt( v )
                   );
    this->addLhs( { a8 , "mu7" } );
    auto a9 = form2( _trial=Xh, _test=Xh);
    a9 = integrate( markedfaces( mesh, "north_domain-7" ),gamma_dir*idt( u )*id( v )/h() )
        +integrate( markedfaces( mesh, "north_domain-8" ),gamma_dir*idt( u )*id( v )/h() )
        +integrate( markedfaces( mesh, "north_domain-9" ),gamma_dir*idt( u )*id( v )/h() );
    this->addLhs( { a9 , "1" } );


    form2( Xh, Xh, M ) = integrate( markedelements( mesh, "domain-1" ), gradt( u )*trans( grad( v ) )  );
    form2( Xh, Xh, M ) += integrate( markedelements( mesh, "domain-2" ), gradt( u )*trans( grad( v ) ) * mu_min_coeff );
    form2( Xh, Xh, M ) += integrate( markedelements( mesh, "domain-3" ), gradt( u )*trans( grad( v ) ) * mu_min_coeff );
    form2( Xh, Xh, M ) += integrate( markedelements( mesh, "domain-4" ), gradt( u )*trans( grad( v ) ) * mu_min_coeff );
    form2( Xh, Xh, M ) += integrate( markedelements( mesh, "domain-5" ), gradt( u )*trans( grad( v ) ) * mu_min_coeff );
    form2( Xh, Xh, M ) += integrate( markedelements( mesh, "domain-6" ), gradt( u )*trans( grad( v ) ) * mu_min_coeff );
    form2( Xh, Xh, M ) += integrate( markedelements( mesh, "domain-7" ), gradt( u )*trans( grad( v ) ) * mu_min_coeff );
    form2( Xh, Xh, M ) += integrate( markedelements( mesh, "domain-8" ), gradt( u )*trans( grad( v ) ) * mu_min_coeff );
    form2( Xh, Xh, M ) += integrate( markedelements( mesh, "domain-9" ), gradt( u )*trans( grad( v ) ) * mu_min_coeff );
    form2( Xh, Xh, M ) +=  integrate( markedfaces( mesh, "north_domain-7" ),
                                      -gradt( u )*vf::N()*id( v ) * mu_min_coeff
                                      -grad( u )*vf::N()*idt( v ) * mu_min_coeff
                                      );
    form2( Xh, Xh, M ) +=  integrate( markedfaces( mesh, "north_domain-8" ),
                                      -gradt( u )*vf::N()*id( v ) * mu_min_coeff
                                      -grad( u )*vf::N()*idt( v ) * mu_min_coeff
                                      );
    form2( Xh, Xh, M ) +=  integrate( markedfaces( mesh, "north_domain-9" ),
                                      -gradt( u )*vf::N()*id( v ) * mu_min_coeff
                                      -grad( u )*vf::N()*idt( v ) * mu_min_coeff
                                      );
    form2( Xh, Xh, M ) += integrate( markedfaces( mesh, "north_domain-7" ),gamma_dir*idt( u )*id( v )/h() );
    form2( Xh, Xh, M ) += integrate( markedfaces( mesh, "north_domain-8" ),gamma_dir*idt( u )*id( v )/h() );
    form2( Xh, Xh, M ) += integrate( markedfaces( mesh, "north_domain-9" ),gamma_dir*idt( u )*id( v )/h() );
    this->addEnergyMatrix( M );

}//initModel()