Exemplo n.º 1
0
TEST(BasicSial,DISABLED_exit_statement_test) {
    std::string job("exit_statement_test");
    sip::DataManager::scope_count=0;
    double x = 3.456;
    double y = -0.1;
    int norb = 3;
    {
        init_setup(job.c_str());
        set_scalar("x",x);
        set_scalar("y",y);
        set_constant("norb",norb);
        std::string tmp = job + ".siox";
        const char* nm= tmp.c_str();
        add_sial_program(nm);
        int segs[]  = {2,3,4,2,3,4,2,3,4,2,3,4,2,3,4};
        set_aoindex_info(15,segs);
        finalize_setup();
    }
    std::stringstream output;
    TestControllerParallel controller(job, true, VERBOSE_TEST, "", output);
    controller.initSipTables();
    controller.run();
    if(attr->is_worker()) {
        EXPECT_DOUBLE_EQ(12, controller.int_value("counter_j"));
        EXPECT_DOUBLE_EQ(4, controller.int_value("counter_i"));
        EXPECT_EQ(0, sip::DataManager::scope_count);
        EXPECT_TRUE(controller.worker_->all_stacks_empty());
        EXPECT_EQ(0, controller.worker_->num_blocks_in_blockmap());
    }
}
Exemplo n.º 2
0
TEST(Sial,persistent_scalars) {
	std::string job("persistent_scalars");
	double x = 3.456;
	double y = -0.1;

	{
		init_setup(job.c_str());
		set_scalar("x", x);
		set_scalar("y", y);
		std::string tmp1 = job + "_1.siox";
		const char* nm1 = tmp1.c_str();
		add_sial_program(nm1);
		std::string tmp2 = job + "_2.siox";
		const char* nm2 = tmp2.c_str();
		add_sial_program(nm2);
		finalize_setup();
	}

	std::stringstream output;
	TestControllerParallel controller(job, true, VERBOSE_TEST, "", output);
	controller.initSipTables();
	controller.run();
	if (attr->is_worker()) {
		ASSERT_DOUBLE_EQ(y, scalar_value("y"));
		ASSERT_DOUBLE_EQ(x, scalar_value("z"));
		ASSERT_DOUBLE_EQ(99.99, scalar_value("zz"));

		std::cout << "wpam:" << std::endl << *controller.wpam_ << std::endl
				<< "%%%%%%%%%%%%" << std::endl;
	}

	//Now do the second program
	//get siox name from setup, load and print the sip tables
	controller.initSipTables();
	controller.run();
	if (attr->is_worker()) {
		ASSERT_DOUBLE_EQ(x + 1, scalar_value("x"));
		ASSERT_DOUBLE_EQ(y, scalar_value("y"));
		ASSERT_DOUBLE_EQ(6, scalar_value("e"));
	}
}
Exemplo n.º 3
0
void SkRect::dump(bool asHex) const {
    SkScalarAsStringType asType = asHex ? kHex_SkScalarAsStringType : kDec_SkScalarAsStringType;

    SkString line;
    if (asHex) {
        SkString tmp;
        line.printf( "SkRect::MakeLTRB(%s, /* %f */\n", set_scalar(&tmp, fLeft, asType), fLeft);
        line.appendf("                 %s, /* %f */\n", set_scalar(&tmp, fTop, asType), fTop);
        line.appendf("                 %s, /* %f */\n", set_scalar(&tmp, fRight, asType), fRight);
        line.appendf("                 %s  /* %f */);", set_scalar(&tmp, fBottom, asType), fBottom);
    } else {
        SkString strL, strT, strR, strB;
        SkAppendScalarDec(&strL, fLeft);
        SkAppendScalarDec(&strT, fTop);
        SkAppendScalarDec(&strR, fRight);
        SkAppendScalarDec(&strB, fBottom);
        line.printf("SkRect::MakeLTRB(%s, %s, %s, %s);",
                    strL.c_str(), strT.c_str(), strR.c_str(), strB.c_str());
    }
    SkDebugf("%s\n", line.c_str());
}
Exemplo n.º 4
0
TEST(Sial,persistent_distributed_array_mpi){
	std::string job("persistent_distributed_array_mpi");
	double x = 3.456;
	int norb = 2;
	int segs[]  = {2,3};

	if (attr->global_rank() == 0){
		init_setup(job.c_str());
		set_scalar("x",x);
		set_constant("norb",norb);
		std::string tmp = job + "1.siox";
		const char* nm= tmp.c_str();
		add_sial_program(nm);
		std::string tmp1 = job + "2.siox";
		const char* nm1= tmp1.c_str();
		add_sial_program(nm1);
		set_aoindex_info(2,segs);
		finalize_setup();
	}


	std::stringstream output;
	TestControllerParallel controller(job, true, true, "", output);

	//run first program
	controller.initSipTables();
	controller.run();
	controller.print_timers(std::cout);
	std::cout << "Rank " << attr->global_rank() << " in persistent_distributed_array_mpi starting second program" << std::endl << std::flush;

	//run second program
	controller.initSipTables();
	controller.run();
	if (attr->is_worker()) {
		int i,j;
		for (i=1; i <= norb ; ++i ){
			for (j = 1; j <= norb; ++j){
			    double firstval = (i-1)*norb + j;
			    std::vector<int> indices;
			    indices.push_back(i);
			    indices.push_back(j);
			    double * block_data = controller.local_block(std::string("a"),indices);
			    size_t block_size = segs[i-1] * segs[j-1];
			    for (size_t count = 0; count < block_size; ++count){
			    	ASSERT_DOUBLE_EQ(3*firstval, block_data[count]);
			    	firstval++;
			    }
			}
		}
	}
	controller.print_timers(std::cout);

}
Exemplo n.º 5
0
TEST(Sial,get_mpi){
	std::string job("get_mpi");
	//create setup_file
	double x = 3.456;
	int norb = 4;
	int segs[]  = {2,3,4,1};

	if (attr->global_rank() == 0){
		init_setup(job.c_str());
		set_scalar("x",x);
		set_constant("norb",norb);
		std::string tmp = job + ".siox";
		const char* nm= tmp.c_str();
		add_sial_program(nm);
		set_aoindex_info(4,segs);
		finalize_setup();
	}

	std::stringstream output;
	TestControllerParallel controller(job, true, VERBOSE_TEST, "", output);
	controller.initSipTables();
	controller.run();

	if(attr->global_rank()==0){
		// Test a(1,1)
		// Get the data for local array block "b"
		int a_slot = controller.worker_->array_slot(std::string("a"));

		sip::index_selector_t a_indices_1;
		a_indices_1[0] = 1; a_indices_1[1] = 1;
		for (int i = 2; i < MAX_RANK; i++) a_indices_1[i] = sip::unused_index_value;
		sip::BlockId a_bid_1(a_slot, a_indices_1);
		std::cout << a_bid_1 << std::endl;
		sip::Block::BlockPtr a_bptr_1 = controller.worker_->get_block_for_reading(a_bid_1);
		sip::Block::dataPtr a_data_1 = a_bptr_1->get_data();
		std::cout << " Comparing block " << a_bid_1 << std::endl;
		for (int i=0; i<segs[0]; i++){
			for (int j=0; j<segs[0]; j++){
				ASSERT_DOUBLE_EQ(42*3, a_data_1[i*segs[0] + j]);
			}
		}
	}
}
Exemplo n.º 6
0
TEST(Sial,put_accumulate_mpi){
	std::string job("put_accumulate_mpi");
	double x = 3.456;
	int norb = 4;
	if (attr->global_rank() == 0){
		init_setup(job.c_str());
		set_scalar("x",x);
		set_constant("norb",norb);
		std::string tmp = job + ".siox";
		const char* nm= tmp.c_str();
		add_sial_program(nm);
		int segs[]  = {2,3,4,1};
		set_aoindex_info(4,segs);
		finalize_setup();
	}
	std::stringstream output;
	TestControllerParallel controller(job, true, VERBOSE_TEST, "", output);
	controller.initSipTables();
	controller.run();

}
Exemplo n.º 7
0
TEST(Sial,all_rank_print){
	std::string job("all_rank_print_test");
	std::cout << "JOBNAME = " << job << std::endl;
	double x = 3.456;
	int norb = 2;
	if (attr->global_rank() == 0){
		init_setup(job.c_str());
		set_scalar("x",x);
		set_constant("norb",norb);
		std::string tmp = job + ".siox";
		const char* nm= tmp.c_str();
		add_sial_program(nm);
		int segs[]  = {2,3};
		set_aoindex_info(2,segs);
		finalize_setup();
	}

	std::stringstream output;
	TestControllerParallel controller(job, true, VERBOSE_TEST, "", output);
	controller.initSipTables();
	controller.run();
}
 void setViews() {
     set_scalar(fViews[0], fPts[1].fX);
     set_scalar(fViews[1], fPts[1].fY);
     set_scalar(fViews[2], fPts[2].fX);
     set_scalar(fViews[3], fPts[2].fY);
 }
Exemplo n.º 9
0
TEST(SimpleMPI,persistent_distributed_array_mpi) {

    sip::GlobalState::reset_program_count();
    sip::SIPMPIAttr &sip_mpi_attr = sip::SIPMPIAttr::get_instance();
    int my_rank = sip_mpi_attr.global_rank();

    std::cout << "****************************************\n";
    sip::DataManager::scope_count=0;
    //create setup_file
    std::string job("persistent_distributed_array_mpi");
    std::cout << "JOBNAME = " << job << std::endl;
    double x = 3.456;
    int norb = 2;
    int segs[]  = {2,3};


    if (attr.global_rank() == 0) {
        init_setup(job.c_str());
        set_scalar("x",x);
        set_constant("norb",norb);
        std::string tmp = job + "1.siox";
        const char* nm= tmp.c_str();
        add_sial_program(nm);
        std::string tmp1 = job + "2.siox";
        const char* nm1= tmp1.c_str();
        add_sial_program(nm1);
        set_aoindex_info(2,segs);
        finalize_setup();
    }

    sip::SIPMPIUtils::check_err(MPI_Barrier(MPI_COMM_WORLD));

    setup::BinaryInputFile setup_file(job + ".dat");
    setup::SetupReader setup_reader(setup_file);

    std::cout << "SETUP READER DATA:\n" << setup_reader<< std::endl;


    //get siox name from setup, load and print the sip tables
    std::string prog_name = setup_reader.sial_prog_list_.at(0);
    std::string siox_dir(dir_name);
    setup::BinaryInputFile siox_file(siox_dir + prog_name);
    sip::SipTables sipTables(setup_reader, siox_file);
    if (!sip_mpi_attr.is_server()) {
        std::cout << "SIP TABLES" << '\n' << sipTables << std::endl;
    }

    if (sip_mpi_attr.global_rank()==0) {
        std::cout << "\n\n\n\n>>>>>>>>>>>>starting SIAL PROGRAM  "<< job << std::endl;
    }

    //create worker and server
    sip::DataDistribution data_distribution(sipTables, sip_mpi_attr);
    sip::GlobalState::set_program_name(prog_name);
    sip::GlobalState::increment_program();
    sip::WorkerPersistentArrayManager wpam;
    sip::ServerPersistentArrayManager spam;

    std::cout << "rank " << my_rank << " reached first barrier" << std::endl << std::flush;
    MPI_Barrier(MPI_COMM_WORLD);
    std::cout << "rank " << my_rank << " passed first barrier" << std::endl << std::flush;

    if (sip_mpi_attr.is_server()) {
        sip::SIPServer server(sipTables, data_distribution, sip_mpi_attr, &spam);
        std::cout << "at first barrier in prog 1 at server" << std::endl << std::flush;
        MPI_Barrier(MPI_COMM_WORLD);
        std::cout<<"passed first barrier at server, starting server" << std::endl;
        server.run();
        spam.save_marked_arrays(&server);
        std::cout << "Server state after termination" << server << std::endl;
    } else {
        sip::SialxTimer sialxTimer(sipTables.max_timer_slots());
        sip::Interpreter runner(sipTables, sialxTimer,  &wpam);
        std::cout << "at first barrier in prog 1 at worker" << std::endl << std::flush;
        MPI_Barrier(MPI_COMM_WORLD);
        std::cout << "after first barrier; starting worker for "<< job  << std::endl;
        runner.interpret();
        wpam.save_marked_arrays(&runner);
        std::cout << "\n end of prog1 at worker"<< std::endl;

    }

    std::cout << std::flush;
    if (sip_mpi_attr.global_rank()==0) {
        std::cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl << std::flush;
        std::cout << "SETUP READER DATA FOR SECOND PROGRAM:\n" << setup_reader<< std::endl;
    }

    std::string prog_name2 = setup_reader.sial_prog_list_.at(1);
    setup::BinaryInputFile siox_file2(siox_dir + prog_name2);
    sip::SipTables sipTables2(setup_reader, siox_file2);

    if (sip_mpi_attr.global_rank()==0) {
        std::cout << "SIP TABLES FOR " << prog_name2 << '\n' << sipTables2 << std::endl;
    }

    sip::DataDistribution data_distribution2(sipTables2, sip_mpi_attr);
    sip::GlobalState::set_program_name(prog_name);
    sip::GlobalState::increment_program();
    std::cout << "rank " << my_rank << " reached second barrier in test" << std::endl << std::flush;
    MPI_Barrier(MPI_COMM_WORLD);
    std::cout << "rank " << my_rank << " passed second barrier in test" << std::endl << std::flush;

    if (sip_mpi_attr.is_server()) {
        sip::SIPServer server(sipTables2, data_distribution2, sip_mpi_attr, &spam);
        std::cout << "barrier in prog 2 at server" << std::endl << std::flush;
        MPI_Barrier(MPI_COMM_WORLD);
        std::cout<< "rank " << my_rank << "starting server for prog 2" << std::endl;
        server.run();
        std::cout<< "rank " << my_rank  << "Server state after termination of prog2" << server << std::endl;
    } else {
        sip::SialxTimer sialxTimer2(sipTables2.max_timer_slots());
        sip::Interpreter runner(sipTables2, sialxTimer2,  &wpam);
        std::cout << "rank " << my_rank << "barrier in prog 2 at worker" << std::endl << std::flush;
        MPI_Barrier(MPI_COMM_WORLD);
        std::cout << "rank " << my_rank << "starting worker for prog2"<< job  << std::endl;
        runner.interpret();
        std::cout << "\nSIAL PROGRAM 2 TERMINATED"<< std::endl;


        // Test contents of blocks of distributed array "b"

        // Get the data for local array block "b"
        int b_slot = runner.array_slot(std::string("lb"));

        // Test b(1,1)
        sip::index_selector_t b_indices_1;
        b_indices_1[0] = 1;
        b_indices_1[1] = 1;
        for (int i = 2; i < MAX_RANK; i++) b_indices_1[i] = sip::unused_index_value;
        sip::BlockId b_bid_1(b_slot, b_indices_1);
        std::cout << b_bid_1 << std::endl;
        sip::Block::BlockPtr b_bptr_1 = runner.get_block_for_reading(b_bid_1);
        sip::Block::dataPtr b_data_1 = b_bptr_1->get_data();
        std::cout << " Comparing block " << b_bid_1 << std::endl;
        double fill_seq_1_1 = 1.0;
        for (int i=0; i<segs[0]; i++) {
            for (int j=0; j<segs[0]; j++) {
                ASSERT_DOUBLE_EQ(fill_seq_1_1, b_data_1[i*segs[0] + j]);
                fill_seq_1_1++;
            }
        }

        // Test b(2, 2)
        sip::index_selector_t b_indices_2;
        b_indices_2[0] = 2;
        b_indices_2[1] = 2;
        for (int i = 2; i < MAX_RANK; i++) b_indices_2[i] = sip::unused_index_value;
        sip::BlockId b_bid_2(b_slot, b_indices_2);
        std::cout << b_bid_2 << std::endl;
        sip::Block::BlockPtr b_bptr_2 = runner.get_block_for_reading(b_bid_2);
        sip::Block::dataPtr b_data_2 = b_bptr_2->get_data();
        std::cout << " Comparing block " << b_bid_2 << std::endl;
        double fill_seq_2_2 = 4.0;
        for (int i=0; i<segs[1]; i++) {
            for (int j=0; j<segs[1]; j++) {
                ASSERT_DOUBLE_EQ(fill_seq_2_2, b_data_2[i*segs[1] + j]);
                fill_seq_2_2++;
            }
        }

        // Test b(2,1)
        sip::index_selector_t b_indices_3;
        b_indices_3[0] = 2;
        b_indices_3[1] = 1;
        for (int i = 2; i < MAX_RANK; i++) b_indices_3[i] = sip::unused_index_value;
        sip::BlockId b_bid_3(b_slot, b_indices_3);
        std::cout << b_bid_3 << std::endl;
        sip::Block::BlockPtr b_bptr_3 = runner.get_block_for_reading(b_bid_3);
        sip::Block::dataPtr b_data_3 = b_bptr_3->get_data();
        std::cout << " Comparing block " << b_bid_3 << std::endl;
        double fill_seq_2_1 = 3.0;
        for (int i=0; i<segs[1]; i++) {
            for (int j=0; j<segs[0]; j++) {
                ASSERT_DOUBLE_EQ(fill_seq_2_1, b_data_3[i*segs[0] + j]);
                fill_seq_2_1++;
            }
        }


    }

    std::cout << "rank " << my_rank << " reached third barrier in test" << std::endl << std::flush;
    MPI_Barrier(MPI_COMM_WORLD);
    std::cout << "rank " << my_rank << " passed third barrier in test" << std::endl << std::flush;

}