Ejemplo n.º 1
0
VD_DEFINE_TEST_WITH_PARAM(ParallelDelegateSpeedTest, RunN) 
{
	RunN(GetParam());
	RecordProperty("Iterations", GetIterationCount());
	RecordProperty("ConnectTime", GetConnectTime());
	RecordProperty("InvokeTime", GetInvokeTime());
	RecordProperty("DisconnectTime", GetDisconnectTime());
}
Ejemplo n.º 2
0
TEST_P(Grid3DPerformanceTests, Grid3DTest)
{
	double concentrationPerCell;
	size_t numElementsPerDimension;
	std::tie(concentrationPerCell, numElementsPerDimension) = GetParam();
	size_t numElements = numElementsPerDimension * numElementsPerDimension * numElementsPerDimension;
	RecordProperty("ElementsPerCell", boost::to_string(concentrationPerCell));
	RecordProperty("NumberOfElements", boost::to_string(numElements));
	RecordProperty("Duration", boost::to_string(performTimingTest(concentrationPerCell, numElementsPerDimension)));
}
    virtual void SetUp() {
        generate_random_uri(source_root, "copyfile_timeout_source", source, 2048);
        generate_random_uri(destination_root, "copyfile_timeout", destination, 2048);

        RecordProperty("Source", source);
        RecordProperty("Destination", source);

        GError* error = NULL;
        int ret = generate_file_if_not_exists(handle, source, "file:///etc/hosts", &error);
        EXPECT_PRED_FORMAT2(AssertGfalSuccess, ret, error);
    }
    virtual void SetUp() {
        mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
        ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay);
        ASSERT_EQ(EGL_SUCCESS, eglGetError());

        EGLint majorVersion;
        EGLint minorVersion;
        EXPECT_TRUE(eglInitialize(mEglDisplay, &majorVersion, &minorVersion));
        ASSERT_EQ(EGL_SUCCESS, eglGetError());
        RecordProperty("EglVersionMajor", majorVersion);
        RecordProperty("EglVersionMajor", minorVersion);
    }
Ejemplo n.º 5
0
TEST(ComediTest,AnalogReadings ) {
    lsampl_t data;
    int ret;
    int subdev = 0;        
    int chan = 0;          
    int range = 0;         
    int aref = AREF_GROUND;
    int num_scans = options.n_scan;
    int num_channels = options.n_chan;
    int readscans;
    std::string prop("/sys/class/comedi/comedi0/read_buffer_pos");

    dev = comedi_open(options.filename);
    ASSERT_TRUE( dev );
    subdev_flags = comedi_get_subdevice_flags(dev, options.subdevice);
    
    RecordProperty("NumScans", num_scans);
    #if 0
    fprintf(stderr, "command before testing:\n");
    dump_cmd(stderr, cmd);
    #endif

    prepare_cmd_lib(dev, options.subdevice, num_scans, num_channels, 1e9 / options.freq, cmd);
    #if 0
    fprintf(stderr, "command before testing:\n");
    dump_cmd(stderr, cmd);
    #endif

    /**
     * Setup the Command structure
     */
    cmd->chanlist_len = 2;
    cmd->stop_arg = num_scans;

    /* verify no problems */
    ret = comedi_command_test(dev, cmd);
    ASSERT_GE( ret, 0 ) << "Comedi Testing of command for device was ok";
    
    /* make sure our scan number hasn't changed */
    ASSERT_EQ( cmd->stop_arg , num_scans );
    ASSERT_EQ( cmd->chanlist_len , 2 );    

    ret = comedi_command(dev, cmd);
    sleep(1);

    ASSERT_GE( ret, 0 ) << "Able to Submit comedi command\n";


    /* Verify that the buffer position has in fact moved
       to say num_scans scans remain in it */
    FILE *fp = fopen(prop.c_str(),"r");
    ASSERT_TRUE( fp ) << "Able to open sysfs property file";
    fscanf(fp,"%d",&readscans );
    
    ASSERT_EQ( readscans, 4*num_scans ) << "Able to read the fifo position 4*" << num_scans << "\n";
    
    fclose(fp);

    comedi_close( dev );
}
Ejemplo n.º 6
0
TEST_F(KTestPlayerLGStateConver, TestLGPremitToOffLine_3)
{
	BOOL	  bResult	 = false;
	int		  nRetCode	 = false;

    RecordProperty("²âÊÔrsLG_WaitForPermitµ½rsOffline״̬ת»»", "Íæ¼Ò״̬Ϊ rsLG_WaitForPermit");

	nRetCode = MakeRoleToPermitState(m_TestRoleInfo, m_dwMapIDInGC, m_nCreatedMapCopyID);
	ASSERT_TRUE(nRetCode);

	nRetCode = ComparePlayerState(m_TestRoleInfo.dwPlayerID, rsLG_WaitForPermit);
	ASSERT_TRUE(nRetCode);

	nRetCode = m_pGameServer->DoPlayerLoginRespond(m_TestRoleInfo.dwPlayerID, FALSE);
	ASSERT_TRUE(nRetCode);

    nRetCode = GATEWAY->CheckReplyLoginData(m_TestRoleInfo.dwPlayerID, eGameLoginUnknownError);
    ASSERT_TRUE(nRetCode);

	nRetCode = GATEWAY->CheckPlayerLeaveGame(m_TestRoleInfo.szAccount);
	ASSERT_TRUE(nRetCode);

	nRetCode = ComparePlayerState(m_TestRoleInfo.dwPlayerID, rsOffline);
	ASSERT_TRUE(nRetCode);
}
TEST_F(TestNameProfile,LIMIT_Number)
{
    NameProfile nameprofile;
    int expectedlimit_max = 22;
    int expectedlimit_min = 1;

    EXPECT_EQ(expectedlimit_max,NameProfile::limit_maxNumber);
    EXPECT_EQ(expectedlimit_min,NameProfile::limit_minNumber);
    RecordProperty("expectedlimit_max",NameProfile::limit_maxNumber);
    RecordProperty("expectedlimit_min",NameProfile::limit_minNumber);

    int lastnamenum = 15;
    NameProfile nameprofile2(lastnamenum);
    EXPECT_EQ(expectedlimit_max,NameProfile::limit_maxNumber);
    EXPECT_EQ(expectedlimit_max,NameProfile::limit_maxNumber);
}
TEST(CheckConfig, audioEffectsConfigurationValidation) {
    RecordProperty("description",
                   "Verify that the effects configuration file is valid according to the schema");
    const char* xmlConfigFile = "/vendor/etc/audio_effects.xml";
    // Not every device uses XML configuration, so only validate
    // if the XML configuration actually exists.
    if (access(xmlConfigFile, F_OK) == 0) {
        ASSERT_VALID_XML(xmlConfigFile, "/data/local/tmp/audio_effects_conf_V2_0.xsd");
    }
}
	void timeMatrixAssembly(std::shared_ptr<DivisibleCubeRepresentation> fem)
	{
		SurgSim::Framework::Timer totalTime;
		totalTime.beginFrame();
		for (int i = 0; i < frameCount; i++)
		{
			fem->getOdeSolver()->computeMatrices(dt, *(fem->getInitialState()), false);
		}
		totalTime.endFrame();
		RecordProperty("Duration", boost::to_string(totalTime.getCumulativeTime()));
	}
	void timeInitializeRepresentation(std::shared_ptr<DivisibleCubeRepresentation> fem)
	{
		SurgSim::Framework::Timer totalTime;
		totalTime.beginFrame();
		for (int i = 0; i < frameCount; i++)
		{
			fem->initializeNoWakeUp();
		}
		totalTime.endFrame();
		RecordProperty("Duration", boost::to_string(totalTime.getCumulativeTime()));
	}
TEST_P(ComponentIntegrationSchemeAndCountParamTest, TimeMatrixInitialization)
{
	int numCubes;
	SurgSim::Math::IntegrationScheme integrationScheme;
	SurgSim::Math::LinearSolver linearSolver;
	std::tie(integrationScheme, linearSolver, numCubes) = GetParam();
	RecordProperty("IntegrationScheme", IntegrationSchemeNames[integrationScheme]);
	RecordProperty("LinearSolver", LinearSolverNames[linearSolver]);
	RecordProperty("CubeDivisions", boost::to_string(numCubes));

	auto fem = std::make_shared<DivisibleCubeRepresentation>("cube", numCubes);
	// We need to add some boundary conditions for the static solver to not run into a singular matrix
	std::const_pointer_cast<SurgSim::Math::OdeState>(fem->getInitialState())->addBoundaryCondition(0);
	std::const_pointer_cast<SurgSim::Math::OdeState>(fem->getInitialState())->addBoundaryCondition(1);
	std::const_pointer_cast<SurgSim::Math::OdeState>(fem->getInitialState())->addBoundaryCondition(2);
	fem->setIntegrationScheme(integrationScheme);
	fem->setLinearSolver(linearSolver);

	timeInitializeRepresentation(fem);
}
    void run()
    {
        unsigned mem_operations_num = 10;
        size_t threads_number = 50;
        bool touch_memory = true;
        size_t size_1MB = 1024*1024;
        size_t alignment = 2*size_1MB;
        size_t alloc_size = 4*size_1MB;

        std::vector<Thread*> threads;
        std::vector<Task*> tasks;

        TimerSysTime timer;
        timer.start();

        // This bug occurs more frequently under stress of multithreaded allocations.
        for (int i=0; i<threads_number; i++) {
		Task* task = new HugePageUnmap(mem_operations_num, touch_memory, alignment, alloc_size, HBW_PAGESIZE_2MB);
		tasks.push_back(task);
		threads.push_back(new Thread(task));
        }

        float elapsed_time = timer.getElapsedTime();

        ThreadsManager threads_manager(threads);
        threads_manager.start();
        threads_manager.barrier();
        threads_manager.release();

        //task release
        for (int i=0; i<tasks.size(); i++) {
		delete tasks[i];
        }

        RecordProperty("threads_number", threads_number);
        RecordProperty("memory_operations_per_thread", mem_operations_num);
        RecordProperty("elapsed_time", elapsed_time);
    }
Ejemplo n.º 13
0
    void post_test(AllocatorFactory::initialization_stat &stat)
    {
        //Calculate (%) distance to the reference time for function calls.
        stat.ref_delta_time = allocator_factory.calc_ref_delta(ref_time,
                                                               stat.total_time);

        std::stringstream elapsed_time;
        elapsed_time << stat.total_time;

        std::stringstream ref_delta_time;
        ref_delta_time << std::fixed << stat.ref_delta_time << std::endl;

        RecordProperty("elapsed_time", elapsed_time.str());
        RecordProperty("ref_delta_time_percent_rate", ref_delta_time.str());

        for (int i=0; i<stat.memory_overhead.size(); i++) {
            std::stringstream node;
            node << "memory_overhad_node_" << i;
            std::stringstream memory_overhead;
            memory_overhead << stat.memory_overhead[i];
            RecordProperty(node.str(), memory_overhead.str());
        }
    }
Ejemplo n.º 14
0
		TEST(ObjectTests, StringObject)
		{
			String value = "abcdefghijklmnopqrstuvwxyz1234567890";

			RecordProperty("value", value);

			ObjectPtr object = createObject(value);
			ASSERT_EQ(Object::STRING, object->getNativeType());
			ASSERT_FALSE(object->isNil());
			ASSERT_TRUE(object->getBoolean());
			ASSERT_THROW(object->getNumber(), ObjectConversionException);
			ASSERT_EQ(value, object->getString());
			ASSERT_THROW(object->getUserdata(), ObjectConversionException);
			ASSERT_EQ(FORMAT("\"%s\"", value.c_str()), object->getReadableString());
		}
Ejemplo n.º 15
0
/**
 * Test if position PID loop works
 */
TEST_P(MotorEncoderTest, PositionPIDController) {
  Reset();

  m_encoder->SetPIDSourceType(PIDSourceType::kDisplacement);
  PIDController pid(0.001f, 0.0005f, 0.0f, m_encoder, m_speedController);
  pid.SetAbsoluteTolerance(20.0f);
  pid.SetOutputRange(-0.3f, 0.3f);
  pid.SetSetpoint(2500);

  /* 10 seconds should be plenty time to get to the setpoint */
  pid.Enable();
  Wait(10.0);
  pid.Disable();

  RecordProperty("PIDError", pid.GetError());

  EXPECT_TRUE(pid.OnTarget()) << "PID loop did not converge within 10 seconds.";
}
Ejemplo n.º 16
0
/**
 * Test if velocity PID loop works
 */
TEST_P(MotorEncoderTest, VelocityPIDController) {
  Reset();

  m_encoder->SetPIDSourceType(PIDSourceType::kRate);
  PIDController pid(1e-5, 0.0f, 3e-5, 8e-5, m_encoder, m_speedController);
  pid.SetAbsoluteTolerance(50.0f);
  pid.SetToleranceBuffer(10);
  pid.SetOutputRange(-0.3f, 0.3f);
  pid.SetSetpoint(2000);

  /* 10 seconds should be plenty time to get to the setpoint */
  pid.Enable();
  Wait(10.0);

  RecordProperty("PIDError", pid.GetAvgError());

  EXPECT_TRUE(pid.OnTarget()) << "PID loop did not converge within 10 seconds. Goal was: " << 2000 << " Error was: " << pid.GetError();

  pid.Disable();
}
Ejemplo n.º 17
0
		TEST(ObjectTests, NumberObject)
		{
			Number low = -1000;
			Number high = 1000;
			Number value = low + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (high - low)));
			
			std::stringstream ss;
			ss << value;

			RecordProperty("value", ss.str());

			ObjectPtr object = createObject(value);
			ASSERT_EQ(Object::NUMBER, object->getNativeType());
			ASSERT_FALSE(object->isNil());
			ASSERT_EQ(value == 0 ? false : true, object->getBoolean());
			ASSERT_EQ(value, object->getNumber());
			ASSERT_EQ(FORMAT("%f", value), object->getString());
			ASSERT_THROW(object->getUserdata(), ObjectConversionException);
			ASSERT_EQ(FORMAT("%f", value), object->getReadableString());
		}
Ejemplo n.º 18
0
TEST_F(KTestPlayerLGStateConver, TestLGLoginToOffLine_2)
{
	BOOL	  bResult	 = false;
	int		  nRetCode	 = false;

     RecordProperty("²âÊÔrsLG_WaitForPermitµ½rsOffline״̬ת»»", "Íæ¼Ò״̬Ϊ rsLG_WaitForLogin");

	nRetCode = MakeRoleToLoginState(m_TestRoleInfo, m_dwMapIDInGC, m_nCreatedMapCopyID);
	ASSERT_TRUE(nRetCode);

	nRetCode = ComparePlayerState(m_TestRoleInfo.dwPlayerID, rsLG_WaitForLogin);
	ASSERT_TRUE(nRetCode);

	m_pGameServer->CloseConnect();

	nRetCode = GATEWAY->CheckPlayerLeaveGame(m_TestRoleInfo.szAccount);
	ASSERT_TRUE(nRetCode);

	nRetCode = ComparePlayerState(m_TestRoleInfo.dwPlayerID, rsOffline);
	ASSERT_TRUE(nRetCode);
}
Ejemplo n.º 19
0
TEST_F(KTestPlayerLGStateConver, TestLGLoginToOnLine)
{
	BOOL	  bResult	 = false;
	int		  nRetCode	 = false;

     RecordProperty("²âÊÔrsLG_WaitForPermitµ½rsOnline״̬ת»»", "Íæ¼Ò״̬Ϊ rsOnline");

	nRetCode = MakeRoleToLoginState(m_TestRoleInfo, m_dwMapIDInGC, m_nCreatedMapCopyID);
	ASSERT_TRUE(nRetCode);

	nRetCode = ComparePlayerState(m_TestRoleInfo.dwPlayerID, rsLG_WaitForLogin);
	ASSERT_TRUE(nRetCode);

	nRetCode = m_pGameServer->DoConfirmPlayerLoginRequest(m_TestRoleInfo.dwPlayerID);
	ASSERT_TRUE(nRetCode);

	nRetCode = m_pGameServer->CheckConfirmPlayerLoginRespond(m_TestRoleInfo.dwPlayerID, TRUE);
	ASSERT_TRUE(nRetCode);

	nRetCode = ComparePlayerState(m_TestRoleInfo.dwPlayerID, rsOnline);
	ASSERT_TRUE(nRetCode);
}
Ejemplo n.º 20
0
TEST_F(KTestPlayerLGStateConver, TestLGPremitToLGLogin)
{
	BOOL	  bResult	 = false;
	int		  nRetCode	 = false;

    RecordProperty("²âÊÔrsLG_WaitForPermitµ½rsLG_WaitForLogin״̬ת»»", "Íæ¼Ò״̬Ϊ rsLG_WaitForLogin");

	nRetCode = MakeRoleToPermitState(m_TestRoleInfo, m_dwMapIDInGC, m_nCreatedMapCopyID);
	ASSERT_TRUE(nRetCode);

	nRetCode = ComparePlayerState(m_TestRoleInfo.dwPlayerID, rsLG_WaitForPermit);
	ASSERT_TRUE(nRetCode);

	nRetCode = m_pGameServer->DoPlayerLoginRespond(m_TestRoleInfo.dwPlayerID, TRUE);
	ASSERT_TRUE(nRetCode);

	nRetCode = GATEWAY->CheckReplyLoginData(m_TestRoleInfo.dwPlayerID, eGameLoginSucceed);
	ASSERT_TRUE(nRetCode);

	nRetCode = ComparePlayerState(m_TestRoleInfo.dwPlayerID, rsLG_WaitForLogin);
	ASSERT_TRUE(nRetCode);
}
	void timeInvertSystem(std::shared_ptr<DivisibleCubeRepresentation> fem)
	{
		fem->getOdeSolver()->computeMatrices(dt, *(fem->getInitialState()), false);
		fem->getOdeSolver()->getLinearSolver()->setMatrix(fem->getOdeSolver()->getSystemMatrix());
		std::shared_ptr<SurgSim::Math::LinearSparseSolveAndInverseCG> solver =
			std::dynamic_pointer_cast<SurgSim::Math::LinearSparseSolveAndInverseCG>(
				fem->getOdeSolver()->getLinearSolver());
		if (solver != nullptr)
		{
			solver->setMaxIterations(static_cast<SurgSim::Math::SparseMatrix::Index>(
										 maxIterationConstant * fem->getNumDof()));
			solver->setTolerance(tolerance);
		}

		SurgSim::Framework::Timer totalTime;
		totalTime.beginFrame();
		for (int i = 0; i < frameCount; i++)
		{
			fem->getOdeSolver()->getLinearSolver()->getInverse();
		}
		totalTime.endFrame();
		RecordProperty("Duration", boost::to_string(totalTime.getCumulativeTime()));
	}
Ejemplo n.º 22
0
IUTEST(FlagTest, Check)
{
    IUTEST_ASSERT_TRUE( listener->called_OnTestProgramStart );
    IUTEST_ASSERT_TRUE( listener->called_OnTestIterationStart );
    IUTEST_ASSERT_TRUE( listener->called_OnEnvironmentsSetUpStart );
    IUTEST_ASSERT_TRUE( listener->called_OnEnvironmentsSetUpEnd );
    IUTEST_ASSERT_TRUE( listener->called_OnTestCaseStart );
    IUTEST_ASSERT_TRUE( listener->called_OnTestStart );

    IUTEST_ASSERT_FALSE( listener->called_OnTestEnd );
    IUTEST_ASSERT_FALSE( listener->called_OnTestCaseEnd );
    IUTEST_ASSERT_FALSE( listener->called_OnEnvironmentsTearDownStart );
    IUTEST_ASSERT_FALSE( listener->called_OnEnvironmentsTearDownEnd );
    IUTEST_ASSERT_FALSE( listener->called_OnTestIterationEnd );
    IUTEST_ASSERT_FALSE( listener->called_OnTestProgramEnd );

    IUTEST_ASSERT_FALSE( listener->called_OnTestPartResult );
    IUTEST_EXPECT_EQ(1, 2);
    IUTEST_ASSERT_TRUE( listener->called_OnTestPartResult );

    IUTEST_ASSERT_FALSE( listener->called_OnTestRecordProperty );
    RecordProperty("dummy", 0);
    IUTEST_ASSERT_TRUE( listener->called_OnTestRecordProperty );
}
Ejemplo n.º 23
0
    void runTest(int prec1, int prec2, int loc1, int loc2, int matrix)
    {
        int status = 0, type;
        oskar_Mem *beam1, *beam2;
        oskar_Timer *timer1, *timer2;
        double time1, time2;

        // Create the timers.
        timer1 = oskar_timer_create(loc1 == OSKAR_GPU ?
                OSKAR_TIMER_CUDA : OSKAR_TIMER_NATIVE);
        timer2 = oskar_timer_create(loc2 == OSKAR_GPU ?
                OSKAR_TIMER_CUDA : OSKAR_TIMER_NATIVE);

        // Run first part.
        type = prec1 | OSKAR_COMPLEX;
        if (matrix) type |= OSKAR_MATRIX;
        beam1 = oskar_mem_create(type, loc1, num_sources, &status);
        oskar_mem_clear_contents(beam1, &status);
        ASSERT_EQ(0, status) << oskar_get_error_string(status);
        createTestData(prec1, loc1, matrix);
        oskar_timer_start(timer1);
        oskar_evaluate_cross_power(num_sources, num_stations,
                jones, 0, beam1, &status);
        time1 = oskar_timer_elapsed(timer1);
        destroyTestData();
        ASSERT_EQ(0, status) << oskar_get_error_string(status);

        // Run second part.
        type = prec2 | OSKAR_COMPLEX;
        if (matrix) type |= OSKAR_MATRIX;
        beam2 = oskar_mem_create(type, loc2, num_sources, &status);
        oskar_mem_clear_contents(beam2, &status);
        ASSERT_EQ(0, status) << oskar_get_error_string(status);
        createTestData(prec2, loc2, matrix);
        oskar_timer_start(timer2);
        oskar_evaluate_cross_power(num_sources, num_stations,
                jones, 0, beam2, &status);
        time2 = oskar_timer_elapsed(timer2);
        destroyTestData();
        ASSERT_EQ(0, status) << oskar_get_error_string(status);

        // Destroy the timers.
        oskar_timer_free(timer1);
        oskar_timer_free(timer2);

        // Compare results.
        check_values(beam1, beam2);

        // Free memory.
        oskar_mem_free(beam1, &status);
        oskar_mem_free(beam2, &status);
        ASSERT_EQ(0, status) << oskar_get_error_string(status);

        // Record properties for test.
        RecordProperty("JonesType", matrix ? "Matrix" : "Scalar");
        RecordProperty("Prec1", prec1 == OSKAR_SINGLE ? "Single" : "Double");
        RecordProperty("Loc1", loc1 == OSKAR_CPU ? "CPU" : "GPU");
        RecordProperty("Time1_ms", int(time1 * 1000));
        RecordProperty("Prec2", prec2 == OSKAR_SINGLE ? "Single" : "Double");
        RecordProperty("Loc2", loc2 == OSKAR_CPU ? "CPU" : "GPU");
        RecordProperty("Time2_ms", int(time2 * 1000));

#ifdef ALLOW_PRINTING
        // Print times.
        printf("  > %s.\n", matrix ? "Matrix" : "Scalar");
        printf("    %s precision %s: %.2f ms, %s precision %s: %.2f ms\n",
                prec1 == OSKAR_SINGLE ? "Single" : "Double",
                loc1 == OSKAR_CPU ? "CPU" : "GPU",
                time1 * 1000.0,
                prec2 == OSKAR_SINGLE ? "Single" : "Double",
                loc2 == OSKAR_CPU ? "CPU" : "GPU",
                time2 * 1000.0);
#endif
    }
Ejemplo n.º 24
0
    virtual void accuracy_test_directed_packed_real_inplace_interleaved()
    {
        try
        {
            DirectedTest::ParametersPackedRealInplaceInterleaved params = GetParam();
            RecordProperty("batch_size", (int)params.batch_size);
            RecordProperty("precision", params.precision);
            RecordProperty("direction", params.direction);
            RecordProperty("dimensions", params.dimensions);
            RecordProperty("length_x", (int)params.lengths[0]);
            if (params.dimensions >= CLFFT_2D) RecordProperty("length_y", (int)params.lengths[1]);
            if (params.dimensions >= CLFFT_3D) RecordProperty("length_z", (int)params.lengths[2]);

            if (params.input_strides.empty())
            {
                RecordProperty("input_strides", 0);
            }
            else
            {
                RecordProperty("input_stride_x", (int)params.input_strides[0]);
                if (params.dimensions >= CLFFT_2D) RecordProperty("input_stride_y", (int)params.input_strides[1]);
                if (params.dimensions >= CLFFT_3D) RecordProperty("input_stride_z", (int)params.input_strides[2]);
            }

            if (params.output_strides.empty())
            {
                RecordProperty("output_strides", 0);
            }
            else
            {
                RecordProperty("output_stride_x", (int)params.output_strides[0]);
                if (params.dimensions >= CLFFT_2D) RecordProperty("output_stride_y", (int)params.output_strides[1]);
                if (params.dimensions >= CLFFT_3D) RecordProperty("output_stride_z", (int)params.output_strides[2]);
            }

            RecordProperty("input_distance", (int)params.input_distance);
            RecordProperty("output_distance", (int)params.output_distance);
            RecordProperty("input_layout", params.input_layout);
            RecordProperty("output_layout", params.output_layout);



            if (params.precision == CLFFT_SINGLE)
            {
                if (params.input_layout == CLFFT_REAL)
                {
                    real_to_complex<float, cl_float, fftwf_complex>(erratic,
                            params.lengths,
                            params.batch_size,
                            params.input_strides,
                            params.output_strides,
                            params.input_distance,
                            params.output_distance,
                            DirectedTest::cl_layout_to_buffer_layout(params.output_layout),
                            placeness::in_place);
                }
                else if (params.output_layout == CLFFT_REAL)
                {
                    complex_to_real<float, cl_float, fftwf_complex>(erratic,
                            params.lengths,
                            params.batch_size,
                            params.input_strides,
                            params.output_strides,
                            params.input_distance,
                            params.output_distance,
                            DirectedTest::cl_layout_to_buffer_layout(params.input_layout),
                            placeness::in_place);
                }
                else
                {
                    throw std::runtime_error("bad layout combination");
                }
            }
            else if (params.precision == CLFFT_DOUBLE)
            {
                if (params.input_layout == CLFFT_REAL)
                {
                    real_to_complex<double, cl_double, fftw_complex>(erratic,
                            params.lengths,
                            params.batch_size,
                            params.input_strides,
                            params.output_strides,
                            params.input_distance,
                            params.output_distance,
                            DirectedTest::cl_layout_to_buffer_layout(params.output_layout),
                            placeness::in_place);
                }
                else if (params.output_layout == CLFFT_REAL)
                {
                    complex_to_real<double, cl_double, fftw_complex>(erratic,
                            params.lengths,
                            params.batch_size,
                            params.input_strides,
                            params.output_strides,
                            params.input_distance,
                            params.output_distance,
                            DirectedTest::cl_layout_to_buffer_layout(params.input_layout),
                            placeness::in_place);
                }
                else
                {
                    throw std::runtime_error("bad layout combination");
                }
            }
            else
            {
                throw std::runtime_error("Random test: this code path should never be executed");
            }
        }
        catch (const std::exception& err)
        {
            handle_exception(err);
        }
    }
TEST_P( mixed_radix, double_precision_complex_to_complex_auto_generated ) {
	size_t problem_size = GetParam();
	RecordProperty("problem_size", (int)problem_size);
	mixed_radix_complex_to_complex<double, cl_double, fftw_complex>(problem_size);
}
Ejemplo n.º 26
0
    void runTest(int prec1, int prec2, int loc1, int loc2, int matrix,
            int extended, double time_average)
    {
        int num_baselines, status = 0, type;
        oskar_Mem *vis1, *vis2;
        oskar_Timer *timer1, *timer2;
        double time1, time2, frequency = 100e6;

        // Create the timers.
        timer1 = oskar_timer_create(loc1 == OSKAR_GPU ?
                OSKAR_TIMER_CUDA : OSKAR_TIMER_NATIVE);
        timer2 = oskar_timer_create(loc2 == OSKAR_GPU ?
                OSKAR_TIMER_CUDA : OSKAR_TIMER_NATIVE);

        // Run first part.
        createTestData(prec1, loc1, matrix);
        num_baselines = oskar_telescope_num_baselines(tel);
        type = prec1 | OSKAR_COMPLEX;
        if (matrix) type |= OSKAR_MATRIX;
        vis1 = oskar_mem_create(type, loc1, num_baselines, &status);
        oskar_mem_clear_contents(vis1, &status);
        ASSERT_EQ(0, status) << oskar_get_error_string(status);
        oskar_sky_set_use_extended(sky, extended);
        oskar_telescope_set_channel_bandwidth(tel, bandwidth);
        oskar_telescope_set_time_average(tel, time_average);
        oskar_timer_start(timer1);
        oskar_cross_correlate(vis1, oskar_sky_num_sources(sky), jones, sky,
                tel, u_, v_, w_, 1.0, frequency, &status);
        time1 = oskar_timer_elapsed(timer1);
        destroyTestData();
        ASSERT_EQ(0, status) << oskar_get_error_string(status);

        // Run second part.
        createTestData(prec2, loc2, matrix);
        num_baselines = oskar_telescope_num_baselines(tel);
        type = prec2 | OSKAR_COMPLEX;
        if (matrix) type |= OSKAR_MATRIX;
        vis2 = oskar_mem_create(type, loc2, num_baselines, &status);
        oskar_mem_clear_contents(vis2, &status);
        ASSERT_EQ(0, status) << oskar_get_error_string(status);
        oskar_sky_set_use_extended(sky, extended);
        oskar_telescope_set_channel_bandwidth(tel, bandwidth);
        oskar_telescope_set_time_average(tel, time_average);
        oskar_timer_start(timer2);
        oskar_cross_correlate(vis2, oskar_sky_num_sources(sky), jones, sky,
                tel, u_, v_, w_, 1.0, frequency, &status);
        time2 = oskar_timer_elapsed(timer2);
        destroyTestData();
        ASSERT_EQ(0, status) << oskar_get_error_string(status);

        // Destroy the timers.
        oskar_timer_free(timer1);
        oskar_timer_free(timer2);

        // Compare results.
        check_values(vis1, vis2);

        // Free memory.
        oskar_mem_free(vis1, &status);
        oskar_mem_free(vis2, &status);
        ASSERT_EQ(0, status) << oskar_get_error_string(status);

        // Record properties for test.
        RecordProperty("SourceType", extended ? "Gaussian" : "Point");
        RecordProperty("JonesType", matrix ? "Matrix" : "Scalar");
        RecordProperty("TimeSmearing", time_average == 0.0 ? "off" : "on");
        RecordProperty("Prec1", prec1 == OSKAR_SINGLE ? "Single" : "Double");
        RecordProperty("Loc1", loc1 == OSKAR_CPU ? "CPU" : "GPU");
        RecordProperty("Time1_ms", int(time1 * 1000));
        RecordProperty("Prec2", prec2 == OSKAR_SINGLE ? "Single" : "Double");
        RecordProperty("Loc2", loc2 == OSKAR_CPU ? "CPU" : "GPU");
        RecordProperty("Time2_ms", int(time2 * 1000));

#ifdef ALLOW_PRINTING
        // Print times.
        printf("  > %s. %s sources. Time smearing %s.\n",
                matrix ? "Matrix" : "Scalar",
                extended ? "Gaussian" : "Point",
                time_average == 0.0 ? "off" : "on");
        printf("    %s precision %s: %.2f ms, %s precision %s: %.2f ms\n",
                prec1 == OSKAR_SINGLE ? "Single" : "Double",
                loc1 == OSKAR_CPU ? "CPU" : "GPU",
                time1 * 1000.0,
                prec2 == OSKAR_SINGLE ? "Single" : "Double",
                loc2 == OSKAR_CPU ? "CPU" : "GPU",
                time2 * 1000.0);
#endif
    }
TEST_P( mixed_radix, single_precision_complex_to_complex_auto_generated ) {
	size_t problem_size = GetParam();
	RecordProperty("problem_size", (int)problem_size);
	mixed_radix_complex_to_complex<float, cl_float, fftwf_complex>(problem_size);
}