当前位置: 首页>>代码示例>>C++>>正文


C++ TaskScheduler::AddTaskSetToPipe方法代码示例

本文整理汇总了C++中TaskScheduler::AddTaskSetToPipe方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskScheduler::AddTaskSetToPipe方法的具体用法?C++ TaskScheduler::AddTaskSetToPipe怎么用?C++ TaskScheduler::AddTaskSetToPipe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TaskScheduler的用法示例。


在下文中一共展示了TaskScheduler::AddTaskSetToPipe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, const char * argv[])
{
	uint32_t maxThreads = GetNumHardwareThreads();
	double* avSpeedUps = new double[ maxThreads ];

	for( uint32_t numThreads = 1; numThreads <= maxThreads; ++numThreads )
	{
		g_TS.Initialize(numThreads);
		double avSpeedUp = 0.0;
		for( int run = 0; run< REPEATS; ++run )
		{

			printf("Run %d.....\n", run);
			Timer tParallel;
			tParallel.Start();

			ParallelReductionSumTaskSet m_ParallelReductionSumTaskSet( 10 * 1024 * 1024 );

			g_TS.AddTaskSetToPipe( &m_ParallelReductionSumTaskSet );

			g_TS.WaitforTaskSet( &m_ParallelReductionSumTaskSet );

			tParallel.Stop();


			printf("Parallel Example complete in \t%fms,\t sum: %" PRIu64 "\n", tParallel.GetTimeMS(), m_ParallelReductionSumTaskSet.m_FinalSum );

			Timer tSerial;
			tSerial.Start();
			uint64_t sum = 0;
			for( uint64_t i = 0; i < (uint64_t)m_ParallelReductionSumTaskSet.m_ParallelSumTaskSet.m_SetSize; ++i )
			{
				sum += i + 1;
			}

			tSerial.Stop();

			if( run >= WARMUPS )
			{
				avSpeedUp += tSerial.GetTimeMS()  / tParallel.GetTimeMS() / RUNS;
			}

			printf("Serial Example complete in \t%fms,\t sum: %" PRIu64 "\n", tSerial.GetTimeMS(), sum );
			printf("Speed Up Serial / Parallel: %f\n\n", tSerial.GetTimeMS()  / tParallel.GetTimeMS() );

		}
		avSpeedUps[numThreads-1] = avSpeedUp;
		printf("\nAverage Speed Up for %d Hardware Threads Serial / Parallel: %f\n", numThreads, avSpeedUp );
	}

	printf("\nHardware Threads, Av Speed Up/s\n" );
	for( uint32_t numThreads = 1; numThreads <= maxThreads; ++numThreads )
	{
		printf("%d, %f\n", numThreads, avSpeedUps[numThreads-1] );
	}

	return 0;
}
开发者ID:MoonCollider,项目名称:enkiTS,代码行数:58,代码来源:Example.cpp

示例2: ExecuteRange

	virtual void    ExecuteRange( TaskSetPartition range, uint32_t threadnum )
	{
		g_TS.AddTaskSetToPipe( &m_ParallelSumTaskSet );
		g_TS.WaitforTaskSet( &m_ParallelSumTaskSet );

		for( uint32_t i = 0; i < m_ParallelSumTaskSet.m_NumPartialSums; ++i )
		{
			m_FinalSum += m_ParallelSumTaskSet.m_pPartialSums[i].count;
		}
	}
开发者ID:MoonCollider,项目名称:enkiTS,代码行数:10,代码来源:Example.cpp

示例3: main

int main(int argc, const char * argv[])
{
	Remotery* rmt;
	rmt_CreateGlobalInstance(&rmt);

    // Set the callbacks BEFORE initialize or we will get no threadstart nor first waitStart calls
    g_TS.GetProfilerCallbacks()->threadStart    = threadStartCallback;
    g_TS.GetProfilerCallbacks()->waitStart      = waitStartCallback;
    g_TS.GetProfilerCallbacks()->waitStop       = waitStopCallback;

	g_TS.Initialize();


	rmt_SetCurrentThreadName("Main");

	double avSpeedUp = 0.0;
	for( int run = 0; run< RUNS; ++run )
	{
		rmt_ScopedCPUSample(Run);

		printf("Run %d.....\n", run);
		ParallelReductionSumTaskSet m_ParallelReductionSumTaskSet( SUMS );
		{
			rmt_ScopedCPUSample(Parallel);

			m_ParallelReductionSumTaskSet.Init();

			g_TS.AddTaskSetToPipe(&m_ParallelReductionSumTaskSet);

			g_TS.WaitforTaskSet(&m_ParallelReductionSumTaskSet);
		}



		volatile uint64_t sum = 0;
		{
			rmt_ScopedCPUSample(Serial);
			for (uint64_t i = 0; i < (uint64_t)m_ParallelReductionSumTaskSet.m_ParallelSumTaskSet.m_SetSize; ++i)
			{
				sum += i + 1;
			}
		}

	}
	rmt_DestroyGlobalInstance(rmt);
	return 0;
}
开发者ID:RobertoMalatesta,项目名称:enkiTSExamples,代码行数:47,代码来源:enkiTSRemoteryExample.cpp


注:本文中的TaskScheduler::AddTaskSetToPipe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。