Пример #1
0
void SeqToolBarView::CacheDrawingInfo()
{
	mPrefW = 0;
	mPrefH = 0;

	FreeCachedInfo();	
	toolref_vec			toolRefs;
	FillVec(toolRefs);

	for (uint32 k = 0; k < toolRefs.size(); k++) {
		// READ TOOL BLOCK
		const AmTool*	tool = toolRefs[k].ReadLock();
		if (tool) {
			BRect		b = tool->IconBounds();
			mPrefW += b.Width() + 1 + mSpace;
			if (b.Height() > mPrefH) mPrefH = b.Height();
			mCachedData.push_back( _SeqCachedTool(tool) );
		}
		toolRefs[k].ReadUnlock(tool);
		// END READ TOOL BLOCK
	}
	/* Oops, I'm empty, prepare myself to just draw a string.
	 */
	if (mCachedData.size() < 1) {
		mPrefW = 4 + StringWidth(EMPTY_STR) + 4;
		mPrefH = 4 + arp_get_font_height(this) + 4;
		return;
	}
	/* Extra space at the end to make it easier to drop in tools.
	 */
	mPrefW += LAST_BUTTON_PAD;
}
Пример #2
0
void BenchmarkLoop(CuContext* context, searchEngine_t engine, int count,
	int numIterations, double* mgpuBenchmarks, double* thrustBenchmarks) {

	////////////////////////////////////////////////////////////////////////////
	// Prepare the device assets.
	printf("ARRAY = %d elements.\n", count);

	// Fill the array with sorted values of random repetition.
	std::vector<T> values;
	FillVec(values, count);

	// Get a list of randomized keys for lower_bound search.
	std::vector<T> keys(MaxQuerySize);
	std::tr1::uniform_int<T> r(0, values.back());
	for(int i(0); i < MaxQuerySize; ++i)
		keys[i] = r(mt19937);

	// Move both arrays to device memory.
	DeviceMemPtr valuesDevice, keysDevice;
	CUresult result = context->MemAlloc(values, &valuesDevice);
	result = context->MemAlloc(keys, &keysDevice);

	// Allocate result space.
	DeviceMemPtr indicesDevice;
	result = context->MemAlloc<uint>(MaxQuerySize, &indicesDevice);

	if(CUDA_SUCCESS != result) {
		printf("Error allocating.\n");
		exit(0);
	}

	// Build the b-tree for MGPU Search.
	searchType_t type = (8 == sizeof(T)) ? SEARCH_TYPE_INT64 : 
		SEARCH_TYPE_INT32;

	int treeSize = searchTreeSize(count, type);
	DeviceMemPtr btreeDevice;
	result = context->ByteAlloc(treeSize, &btreeDevice);

	searchStatus_t status = searchBuildTree(engine, count, type, 
		valuesDevice->Handle(), btreeDevice->Handle());


	////////////////////////////////////////////////////////////////////////////
	

	for(int q(0); q < NumQuerySizes; ++q) {
		int querySize = QuerySizes[q][0];
		int iterations = numIterations * QuerySizes[q][1];

		mgpuBenchmarks[q] = 0;
		thrustBenchmarks[q] = 0;
		printf("\t(%d, %d):\n", count, querySize);

		for(int t(0); t < NumTests; ++t) {
			// Test MGPU
			double throughput = MgpuBenchmark(engine, count, valuesDevice,
				type, btreeDevice, iterations, querySize, keysDevice,
				indicesDevice, &values[0], &keys[0]);
			printf("\t\t%10.3f M/s\t\t", throughput / 1.0e6);
			mgpuBenchmarks[q] = std::max(mgpuBenchmarks[q], throughput);

			// Test thrust
			throughput = ThrustBenchmark(count, valuesDevice, iterations,
				querySize, keysDevice, indicesDevice, &values[0], &keys[0]);
			printf("\t\t%10.3f M/s\n", throughput / 1.0e6);
			thrustBenchmarks[q] = std::max(thrustBenchmarks[q], throughput);
		}
	}
	printf("\n");
}