コード例 #1
0
int _tmain(int argc, char* argv[])
{
//1cmd_file.txt 2config_file.txt 3mem_init.txt 4regs_dump.txt 5mem_dump.txt 6time.txt 7committed.txt 8hitrate.txt 9L1i.txt 10L1d.txt 11L2i.txt 12L2d.txt
//1cmd_file1.txt 2cmd_file2.txt 3config_file.txt 4mem_init.txt 5regs_dump.txt 6mem_dump.txt 7time.txt 8committed.txt 9hitrate.txt 10trace1.txt 11trace2.txt

	if(argc!=12)
	{
		printf("Wrong number of command line arguments!\n");
		exit(1);
	}

	if (ini_parse(argv[3], handler, &configuration) < 0) {
		printf("Can't load '%s' file\n",argv[1]);
		exit(1);
	}

	ram = new int[MEMORY_SIZE/4];
	if (ram == NULL)
		exit(1);

	ReadMemInitFile(argv[4]);

	ParseCMDfile(argv[1]);

	InitCaches(&configuration);

	StartSimulator();

	printf("simulation done!\n");

	WriteMemoryDumpToFile(argv[6]);

	WriteRegisterDumpToFile(argv[5]);

	WriteExceutionTime(argv[7]);

	WriteInstructionCount(argv[8]);

	WriteHitRatioAndAMAT(argv[9]);

	
	printf("all results written to files!\n");

//	DestroyCaches();

	free(ram);

	return 0;
}
コード例 #2
0
status_t _GlReplicateMap::Algo(float* line, float* at, int32 size, uint32 flags) const
{
	const GlAlgo1d*		map = Algo1dAt(_MAP_INDEX);
	if (!map) return B_ERROR;
	/* 0.5 is 2 replications -- anything below that is obviously meaningless.
	 */
	if (mDepth < 0.50) return map->Algo(line, at, size, flags);
	/* Default to repping every element in the line -- i.e, depth is 1.
	 */
	int32			repCount = size;
	int32			repSize = 1;
	if (mDepth < 1.0) {
		repCount = int32(floor(1 / (1 - mDepth)));
		repSize = int32(ceil(size / float(repCount)));
		if (repSize <= 0) return map->Algo(line, at, size, flags);
		if (repSize > size) repSize = size;
	}
	
	status_t		err = InitCaches(line, at, size, repSize);
	if (err != B_OK) return err;

	int32			from = 0, to = repSize - 1;
	int32			curRep = 0;
	while (from < size) {
		if (to >= size) to = size - 1;
		ArpVALIDATE(to >= from, break);
		/* Run my map on a cache of the line and copy it over.
		 */
		memcpy(mLineCache.n, mLineSrcCache.n, repSize * 4);
		if (at) memcpy(mAtCache.n, mAtSrcCache.n, repSize * 4);
		((GlAlgo1d*)map)->SetStep(curRep / float(repCount));
		map->Algo(mLineCache.n, (at) ? mAtCache.n : 0, repSize, flags);
		/* Copy over the results.
		 */
		for (int32 k = from; k <= to; k++) line[k] *= mLineCache.n[k - from];

		from = to + 1;
		to = from + repSize - 1;
		curRep++;
		ArpASSERT(curRep <= repCount);
		if (curRep > repCount) curRep = repCount;
	}
	return B_OK;
}