亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? marsutils.cu

?? GPU實現的MapReduce framework,對于學習并行編程和cuda平臺的編程方面有著極好的參考價值
?? CU
?? 第 1 頁 / 共 3 頁
字號:
/**
 *This is the source code for Mars, a MapReduce framework on graphics
 *processors.
 *Author: Wenbin Fang (HKUST), Bingsheng He (HKUST)
 *Mentor: Naga K. Govindaraju (Microsoft Corp.), Qiong Luo (HKUST), Tuyong
 *Wang (Sina.com).
 *If you have any question on the code, please contact us at {saven,
 *wenbin, luo}@cse.ust.hk.
 *The copyright is held by HKUST. Mars is provided "as is" without any 
 *guarantees of any kind.
 */

//--------------------------------------------------
//runtime functions which can be called by users
//1, Required
//2, Iterators
//3, Debug tools
//--------------------------------------------------
#include "MarsInc.h"

//========================================================
//Required
//======================================================== 
//--------------------------------------------------------
//factory function, get a default runtime configuration
//--------------------------------------------------------
Spec_t *GetDefaultSpec()
{
	//EnterFunc("GetDefaultSpec");
	Spec_t *spec = (Spec_t*)BenMalloc(sizeof(Spec_t));

	BenMemset(&spec->inputFile, 0, sizeof(FileName_t));
	BenMemset(&spec->interFile, 0, sizeof(FileName_t));
	BenMemset(&spec->outputFile, 0, sizeof(FileName_t));

	spec->inputFile.keyFile = BenStrDup(DEFAULT_INPUT_KEY_FILE);
	spec->inputFile.valFile = BenStrDup(DEFAULT_INPUT_VAL_FILE);
	spec->inputFile.indexFile = BenStrDup(DEFAULT_INPUT_INDEX_FILE);

	spec->inputChunk = (ChunkInfo_t*)BenMalloc(sizeof(ChunkInfo_t));
	spec->interChunk = (ChunkInfo_t*)BenMalloc(sizeof(ChunkInfo_t));
	spec->outputChunk = (ChunkInfo_t*)BenMalloc(sizeof(ChunkInfo_t));
	
	spec->cpuSched = (Schedule_t*)BenMalloc(sizeof(Schedule_t));
	spec->gpuSched = (Schedule_t*)BenMalloc(sizeof(Schedule_t));

	spec->gpuSched->gpuMapSharedMemSize = 0;
	spec->gpuSched->gpuReduceSharedMemSize = 0;

	spec->sortInfo = (SortInfo_t*)BenMalloc(sizeof(SortInfo_t));
	spec->sortInfo->fullChunkCount = DEFAULL_FULL_SORT_CHUNK_COUNT;
	spec->sortInfo->chunks = (SortChunk_t*)BenMalloc(sizeof(SortChunk_t)*spec->sortInfo->fullChunkCount);

	spec->flushThreshhold = DEFAULT_THRESHHOLD;

	//LeaveFunc("GetDefaultSpec");
	return spec;
}

//------------------------------------------------
//Add input records
//------------------------------------------------
size_t d_keyChunkSize = 0;
size_t d_valChunkSize = 0;
size_t d_indexChunkSize = 0;

static int2 curOffset;
static int3 curChunkNum;
static void AddMapInputRecordSingle(Spec_t*		spec, 
					   void*		key, 
					   void*		val,
					   size_t		keySize, 
					   size_t		valSize)
{
	//EnterFunc("AddMapInputRecord");
	BEN_ASSERT(spec != NULL);

	int index = spec->inputChunk->recCount;

	const size_t dataChunkSize = 1024*1024*16;

	if (spec->totalInputRecCount > 0)
	{
		size_t xAllSize = dataChunkSize*curChunkNum.x;
		if ( xAllSize < (curOffset.x + keySize))
		{
			spec->inputChunk->keys = (char*)BenRealloc(spec->inputChunk->keys, 
					xAllSize, (++curChunkNum.x)*dataChunkSize);

			d_keyChunkSize += dataChunkSize;
		}
		BenMemcpy(spec->inputChunk->keys+curOffset.x, key, keySize);

		size_t yAllSize = dataChunkSize*curChunkNum.y;
		if (yAllSize < (curOffset.y + valSize))
		{
			spec->inputChunk->vals = (char*)BenRealloc(spec->inputChunk->vals,
				yAllSize, (++curChunkNum.y)*dataChunkSize);

			d_valChunkSize += dataChunkSize;
		}
		BenMemcpy(spec->inputChunk->vals+curOffset.y, val, valSize);		

		size_t zAllSize = dataChunkSize*curChunkNum.z;
		if (zAllSize < (spec->inputChunk->recCount+1)*sizeof(int4))
		{
			spec->inputChunk->index = (int4*)BenRealloc((void*)spec->inputChunk->index, 
				zAllSize, (++curChunkNum.z)*dataChunkSize);

			d_indexChunkSize += dataChunkSize;
		}
	}
	else
	{
		spec->inputChunk->keys = (char*)BenMalloc(dataChunkSize);
		if (NULL == spec->inputChunk->keys) exit(-1);
		BenMemcpy(spec->inputChunk->keys, key, keySize);

		spec->inputChunk->vals = (char*)BenMalloc(dataChunkSize);
		if (NULL == spec->inputChunk->vals) exit(-1);
		BenMemcpy(spec->inputChunk->vals, val, valSize);

		spec->inputChunk->index = (int4*)BenMalloc(dataChunkSize);

		curChunkNum.x++;
		curChunkNum.y++;
		curChunkNum.z++;

		d_keyChunkSize += dataChunkSize;
		d_valChunkSize += dataChunkSize;
		d_indexChunkSize += dataChunkSize;
	}

	spec->inputChunk->index[index].x = curOffset.x;
	spec->inputChunk->index[index].y = keySize;
	spec->inputChunk->index[index].z = curOffset.y;
	spec->inputChunk->index[index].w = valSize;

	curOffset.x += keySize;
	curOffset.y += valSize;

	spec->inputChunk->keySize += keySize;
	spec->inputChunk->valSize += valSize;
	spec->inputChunk->indexSize += sizeof(int4);
	spec->inputChunk->recCount++;
	spec->totalInputRecCount++;

	//flush in memory buffer to disk

	//LeaveFunc("AddMapInputRecord");
}
	
static int2 localIndex;
static void AddMapInputRecordMem(Spec_t*		spec, 
					   void*		key, 
					   void*		val,
					   size_t		keySize, 
					   size_t		valSize)
{
	//EnterFunc("AddMapInputRecord");
	BEN_ASSERT(spec != NULL);

	int index = spec->inputChunk->recCount;

	const size_t dataChunkSize = 1024*1024*16;

	if (spec->totalInputRecCount > 0)
	{
		size_t xAllSize = dataChunkSize*curChunkNum.x;
		if ( xAllSize < (curOffset.x + keySize))
		{
			spec->inputChunk->keys = (char*)BenRealloc(spec->inputChunk->keys, 
					xAllSize, (++curChunkNum.x)*dataChunkSize);

			d_keyChunkSize += dataChunkSize;
		}
		BenMemcpy(spec->inputChunk->keys+curOffset.x, key, keySize);

		size_t yAllSize = dataChunkSize*curChunkNum.y;
		if (yAllSize < (curOffset.y + valSize))
		{
			spec->inputChunk->vals = (char*)BenRealloc(spec->inputChunk->vals,
				yAllSize, (++curChunkNum.y)*dataChunkSize);

			d_valChunkSize += dataChunkSize;
		}
		BenMemcpy(spec->inputChunk->vals+curOffset.y, val, valSize);		

		size_t zAllSize = dataChunkSize*curChunkNum.z;
		if (zAllSize < (spec->inputChunk->recCount+1)*sizeof(int4))
		{
			spec->inputChunk->index = (int4*)BenRealloc((void*)spec->inputChunk->index, 
				zAllSize, (++curChunkNum.z)*dataChunkSize);

			d_indexChunkSize += dataChunkSize;
		}
	}
	else
	{
		spec->inputChunk->keys = (char*)BenMalloc(dataChunkSize);
		if (NULL == spec->inputChunk->keys) exit(-1);
		BenMemcpy(spec->inputChunk->keys, key, keySize);

		spec->inputChunk->vals = (char*)BenMalloc(dataChunkSize);
		if (NULL == spec->inputChunk->vals) exit(-1);
		BenMemcpy(spec->inputChunk->vals, val, valSize);

		spec->inputChunk->index = (int4*)BenMalloc(dataChunkSize);

		curChunkNum.x++;
		curChunkNum.y++;
		curChunkNum.z++;

		d_keyChunkSize += dataChunkSize;
		d_valChunkSize += dataChunkSize;
		d_indexChunkSize += dataChunkSize;
	}

	spec->inputChunk->index[index].x = localIndex.x;
	spec->inputChunk->index[index].y = keySize;
	spec->inputChunk->index[index].z = localIndex.x;
	spec->inputChunk->index[index].w = valSize;

	curOffset.x += keySize;
	curOffset.y += valSize;

	localIndex.x += keySize;
	localIndex.y += valSize;

	spec->inputChunk->keySize += keySize;
	spec->inputChunk->valSize += valSize;
	spec->inputChunk->indexSize += sizeof(int4);
	spec->inputChunk->recCount++;
	spec->totalInputRecCount++;

	//flush in memory buffer to disk

	//LeaveFunc("AddMapInputRecord");
}

static void AddMapInputRecordFile(Spec_t*		spec, 
					   void*		key, 
					   void*		val,
					   size_t		keySize, 
					   size_t		valSize)
{
	//flush buffer to file
	if (spec->inputChunk->recCount >= spec->flushThreshhold)
	{
		/*for (int i = 0; i < spec->inputChunk->recCount; i++)
		{
			spec->inputChunk->index[i].x += spec->inputChunk->keyOffset;
			spec->inputChunk->index[i].z += spec->inputChunk->valOffset;
		}*/
		if (spec->totalInputRecCount > spec->flushThreshhold)
		{
			BenAppendFile(spec->inputFile.keyFile, 
				spec->inputChunk->keys, spec->inputChunk->keySize);
			BenAppendFile(spec->inputFile.valFile, 
				spec->inputChunk->vals, spec->inputChunk->valSize);
			BenAppendFile(spec->inputFile.indexFile, 
				spec->inputChunk->index, spec->inputChunk->indexSize);
		}
		else
		{
			BenWriteFile(spec->inputFile.keyFile, 
				spec->inputChunk->keys, spec->inputChunk->keySize);
			BenWriteFile(spec->inputFile.valFile, 
				spec->inputChunk->vals, spec->inputChunk->valSize);
			BenWriteFile(spec->inputFile.indexFile, 
				spec->inputChunk->index, spec->inputChunk->indexSize);
		}

		spec->inputChunk->keyOffset += spec->inputChunk->keySize;
		spec->inputChunk->valOffset += spec->inputChunk->valSize;
		spec->inputChunk->recCount = 0;
		spec->inputChunk->keySize = 0;
		spec->inputChunk->valSize = 0;
		spec->inputChunk->indexSize = 0;
		curOffset.x = 0;
		curOffset.y = 0;
	}

	//put record temporally in memory
	AddMapInputRecordMem(spec, key, val, keySize, valSize);
}

void AddMapInputRecord(Spec_t*		spec, 
					   void*		key, 
					   void*		val,
					   size_t		keySize, 
					   size_t		valSize)
{
	if (spec->mode & USE_MEM)
		AddMapInputRecordSingle(spec, key, val, keySize, valSize);
	else if (spec->mode & USE_FILE)
		AddMapInputRecordFile(spec, key, val, keySize, valSize);
	else
		return ;
}

void ResetInput(Spec_t *spec)
{
	if (spec->mode & USE_MEM)
	{
		BenFree((char**)&(spec->inputChunk->keys), d_keyChunkSize);
		BenFree((char**)&(spec->inputChunk->vals), d_valChunkSize);
		BenFree((char**)&(spec->inputChunk->index), d_indexChunkSize);

		d_keyChunkSize = 0;
		d_valChunkSize = 0;
		d_indexChunkSize = 0;
		localIndex.x = 0;
		localIndex.y = 0;
		curOffset.x = 0;
		curOffset.y = 0;
		curChunkNum.x = 0;
		curChunkNum.y = 0;
		curChunkNum.z = 0;

		BenMemset(spec->inputChunk, 0, sizeof(ChunkInfo_t));
		spec->totalInputRecCount = 0;
	}
}

void ResetInter(Spec_t *spec)
{
	if (spec->mode & USE_MEM)
	{
		BenFree((char**)&(spec->interChunk->keys), spec->interChunk->keySize);
		BenFree((char**)&(spec->interChunk->vals), spec->interChunk->valSize);
		BenFree((char**)&(spec->interChunk->index), spec->interChunk->indexSize);
		BenFree((char**)&(spec->interChunk->keyListRange), sizeof(int2)*spec->interChunk->diffKeyCount);		
	
		BenMemset(spec->interChunk, 0, sizeof(ChunkInfo_t));
		spec->totalInterRecCount = 0;
		spec->totalDiffKeyCount = 0;
	}
}

void ResetOutput(Spec_t *spec)
{
	if (spec->mode & USE_MEM)
	{
		BenFree((char**)&(spec->outputChunk->keys), spec->outputChunk->keySize);
		BenFree((char**)&spec->outputChunk->vals, spec->outputChunk->valSize);
		BenFree((char**)&spec->outputChunk->index, spec->outputChunk->indexSize);
		BenFree((char**)&(spec->outputChunk->keyListRange), sizeof(int2)*spec->outputChunk->diffKeyCount);
		BenMemset(spec->outputChunk, 0, sizeof(ChunkInfo_t));
	}
}

static void FlushToDisk(ChunkInfo_t *chunk, FileName_t *file)
{
	BenAppendFile(file->keyFile, chunk->keys, chunk->keySize);
	BenAppendFile(file->valFile, chunk->vals, chunk->valSize);
	BenAppendFile(file->indexFile, chunk->index, chunk->indexSize);
}

void FlushInputToDisk(Spec_t *spec)
{
	if (spec->inputChunk->recCount > 0 &&
		spec->mode & USE_FILE)
	{
		FlushToDisk(spec->inputChunk, &(spec->inputFile));

		BenFree((char**)&(spec->inputChunk->keys), d_keyChunkSize);
		BenFree((char**)&(spec->inputChunk->vals), d_valChunkSize);
		BenFree((char**)&(spec->inputChunk->index), d_indexChunkSize);
		
		spec->inputChunk->recCount = 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩av高清在线观看| 欧美一区二区在线播放| 欧美国产日本视频| 国产成人午夜精品影院观看视频| 日韩欧美色电影| 国产麻豆精品95视频| 国产视频视频一区| 色婷婷av一区二区三区大白胸| 亚洲欧美激情小说另类| 欧美日韩综合在线免费观看| 视频一区欧美日韩| 久久蜜臀中文字幕| 成人毛片在线观看| 亚洲精品成人在线| 日韩欧美成人一区| 成人毛片视频在线观看| 亚洲综合图片区| 日韩欧美你懂的| 成人妖精视频yjsp地址| 亚洲精品视频免费观看| 91麻豆精品国产自产在线观看一区 | 亚洲h精品动漫在线观看| 91麻豆精品国产91久久久久久久久 | 久久久久久亚洲综合| 成人一区在线观看| 亚洲一区二区视频在线观看| 日韩视频一区二区在线观看| 国产成人综合网站| 亚洲高清视频中文字幕| 欧美不卡一区二区三区四区| 不卡免费追剧大全电视剧网站| 亚洲电影第三页| 国产欧美综合色| 欧美日韩国产色站一区二区三区| 国产一区二区三区免费在线观看| 国产精品久久久久永久免费观看| 欧美日韩成人综合在线一区二区| 国产精品一区二区在线播放 | 国产日韩精品一区二区三区| 欧美三电影在线| 99热99精品| 久久精品久久综合| 亚洲伦理在线精品| 久久久久综合网| 91精品国产综合久久精品app | 久久精品国产第一区二区三区| 亚洲欧美日韩一区二区| 欧美变态tickle挠乳网站| 91麻豆6部合集magnet| 久久精品国产精品亚洲精品| 亚洲成人中文在线| 国产精品久久影院| 2021中文字幕一区亚洲| 欧美精品一二三区| 91在线观看污| 成人免费视频视频| 狠狠网亚洲精品| 天堂va蜜桃一区二区三区漫画版| 亚洲欧美国产三级| 国产片一区二区| 久久麻豆一区二区| 欧美一级生活片| 欧美日韩国产另类不卡| 在线看不卡av| 一道本成人在线| 91亚洲精品久久久蜜桃| 国产99久久久久| 国产精品一区二区在线看| 精品一二三四区| 久久成人18免费观看| 免费亚洲电影在线| 日韩经典中文字幕一区| 午夜欧美2019年伦理| 亚洲一区欧美一区| 亚洲福利一区二区| 亚洲第四色夜色| 亚洲成人av福利| 午夜日韩在线电影| 天堂在线亚洲视频| 琪琪久久久久日韩精品| 蜜桃视频在线观看一区| 美女脱光内衣内裤视频久久影院| 麻豆一区二区三| 国产美女精品在线| 国产不卡视频一区二区三区| 丁香六月久久综合狠狠色| 国产91在线看| 91丨porny丨蝌蚪视频| 日本高清免费不卡视频| 欧美三级日韩三级| 日韩欧美国产小视频| 久久久久久久av麻豆果冻| 欧美国产精品中文字幕| 自拍偷拍欧美激情| 石原莉奈一区二区三区在线观看| 日韩精品久久久久久| 国产毛片精品一区| 99国产精品国产精品久久| 欧美天堂一区二区三区| 日韩一二三区视频| 国产亚洲精品精华液| 亚洲视频在线观看三级| 日欧美一区二区| 国产不卡视频一区| 色94色欧美sute亚洲线路一ni | 亚洲一卡二卡三卡四卡| 奇米777欧美一区二区| 国产黄色精品网站| 91国产视频在线观看| 欧美一卡二卡三卡| 亚洲欧洲国产专区| 日韩成人一区二区| 成人毛片在线观看| 777午夜精品视频在线播放| 久久综合成人精品亚洲另类欧美| 最新中文字幕一区二区三区| 午夜久久久久久| 国产成人综合视频| 欧美日韩成人综合天天影院 | 狠狠v欧美v日韩v亚洲ⅴ| av一二三不卡影片| 在线电影国产精品| 中文字幕av在线一区二区三区| 亚洲午夜视频在线观看| 国产成人久久精品77777最新版本| 日本福利一区二区| 欧美精品一区二区久久婷婷 | 日韩午夜在线影院| 成人欧美一区二区三区在线播放| 青青草97国产精品免费观看| 91麻豆精品秘密| 久久精品在线免费观看| 午夜伊人狠狠久久| av在线这里只有精品| 日韩精品自拍偷拍| 一二三四区精品视频| 国产大陆a不卡| 日韩欧美一级精品久久| 亚洲国产精品一区二区久久| 懂色av中文字幕一区二区三区| 欧美精品亚洲二区| 亚洲一区成人在线| 色伊人久久综合中文字幕| 久久精品夜色噜噜亚洲a∨| 理论片日本一区| 欧美一级一区二区| 亚洲激情av在线| 成人丝袜高跟foot| 久久精品视频在线看| 黄一区二区三区| 精品国产电影一区二区| 婷婷国产v国产偷v亚洲高清| 91久久一区二区| 1区2区3区欧美| 不卡一区二区三区四区| 国产色爱av资源综合区| 经典三级视频一区| 欧美精品一区二区三区久久久| 日本中文一区二区三区| 欧美日韩国产片| 午夜婷婷国产麻豆精品| 欧美三级欧美一级| 亚洲成av人片| 7777精品伊人久久久大香线蕉经典版下载 | 亚洲综合999| 在线亚洲一区观看| 一区2区3区在线看| 欧美亚洲日本一区| 亚洲国产美女搞黄色| 欧美日韩免费在线视频| 性感美女极品91精品| 91麻豆精品国产综合久久久久久| 日韩国产精品久久久| 欧美一区二区国产| 久久99久久精品欧美| 久久久亚洲综合| 成人午夜精品一区二区三区| 国产精品无圣光一区二区| a4yy欧美一区二区三区| 亚洲人成在线观看一区二区| 日本道在线观看一区二区| 亚洲mv在线观看| 日韩美女一区二区三区四区| 国产盗摄女厕一区二区三区| 国产精品日韩成人| 一本大道久久a久久综合| 亚洲国产中文字幕在线视频综合| 7777女厕盗摄久久久| 精品一区二区av| 国产精品国产自产拍高清av| 欧美少妇一区二区| 久久激情五月婷婷| 亚洲国产经典视频| 欧洲视频一区二区| 免费成人在线视频观看| 欧美国产日韩a欧美在线观看 | 美国毛片一区二区| 欧美激情资源网| 欧美日本国产视频| 国产成人自拍网|