亚洲欧美第一页_禁久久精品乱码_粉嫩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人导航| 欧美韩日一区二区三区四区| 亚洲国产婷婷综合在线精品| 国产毛片精品一区| 欧美日韩三级视频| 国产精品美女久久久久久久久久久| 一区二区三区.www| thepron国产精品| 精品嫩草影院久久| 亚洲va在线va天堂| 一本到一区二区三区| 国产午夜精品在线观看| 老司机午夜精品| 欧美一区中文字幕| 污片在线观看一区二区| 白白色亚洲国产精品| 久久亚洲精精品中文字幕早川悠里| 性久久久久久久| 欧美在线观看视频在线| 国产精品乱子久久久久| 久久国产欧美日韩精品| 欧美一区二区三区免费视频| 亚洲妇熟xx妇色黄| 欧美日韩精品一区二区三区四区 | 国产一区二区三区四区在线观看| 色老综合老女人久久久| 国产精品日日摸夜夜摸av| 国产一区二区精品久久| 日韩精品一区二区三区蜜臀 | 五月婷婷欧美视频| 欧美自拍偷拍一区| 亚洲国产三级在线| 欧美日韩色综合| 日韩综合小视频| 7777精品久久久大香线蕉| 亚洲动漫第一页| 在线视频中文字幕一区二区| 亚洲精品成人少妇| 欧美唯美清纯偷拍| 亚洲国产你懂的| 在线不卡中文字幕播放| 丝袜美腿亚洲综合| 日韩午夜av电影| 国产一区欧美一区| 国产日韩精品视频一区| 成人av影视在线观看| 成人欧美一区二区三区视频网页| 成人精品视频网站| 亚洲成人精品一区| 在线不卡免费av| 久久精品理论片| 国产精品无圣光一区二区| 99精品1区2区| 亚洲国产欧美在线| 久久久影视传媒| 一本一本久久a久久精品综合麻豆| 一区二区三区在线视频观看58 | 国产精品88av| 国产精品美日韩| 欧美午夜片在线看| 久久精品国产精品亚洲综合| 久久九九久久九九| 色综合久久久久| 久久精品免费看| 亚洲欧美激情插| 日韩午夜精品视频| jizz一区二区| 日产国产高清一区二区三区| 中文字幕av一区二区三区| 在线精品观看国产| 国产不卡一区视频| 亚洲一区在线视频观看| 久久尤物电影视频在线观看| 91精彩视频在线| 国产一区二区三区精品欧美日韩一区二区三区 | 91麻豆精品国产91久久久| 久久99精品网久久| 中文字幕在线一区| 欧美一区二区三区视频在线观看| heyzo一本久久综合| 日本成人在线一区| 亚洲蜜桃精久久久久久久| 精品国产伦一区二区三区观看体验| 99re在线视频这里只有精品| 久久99精品国产| 亚洲国产毛片aaaaa无费看| 26uuu久久天堂性欧美| 欧美日韩一级大片网址| 成人激情小说网站| 久久www免费人成看片高清| 一区二区三区精品在线| 欧美国产成人精品| xvideos.蜜桃一区二区| 这里只有精品视频在线观看| 91久久精品一区二区| 丁香激情综合五月| 国产乱码精品一区二区三区忘忧草 | 亚洲日本一区二区三区| 欧美本精品男人aⅴ天堂| 欧美日韩视频在线第一区 | 日韩免费一区二区三区在线播放| 一本在线高清不卡dvd| 成人av网站在线| 国产麻豆精品95视频| 蜜臀av亚洲一区中文字幕| 亚洲国产一区在线观看| 国产精品入口麻豆九色| 久久欧美一区二区| 久久尤物电影视频在线观看| 日韩精品一区二| 精品日产卡一卡二卡麻豆| 欧美日韩你懂得| 欧美丝袜第三区| 在线一区二区三区四区五区 | 欧美一区二区日韩一区二区| 欧美影院午夜播放| 91视频免费播放| 99久久er热在这里只有精品66| 成人国产精品免费网站| 成人福利视频网站| 不卡视频免费播放| 色天使久久综合网天天| 日本韩国欧美在线| 91久久国产最好的精华液| 欧美性生活大片视频| 在线电影院国产精品| 日韩美女天天操| 久久久久久电影| 1区2区3区欧美| 亚洲第一成人在线| 青青草精品视频| 国产真实乱子伦精品视频| 99久久精品国产观看| 91黄色免费看| 欧美一级日韩免费不卡| 26uuu亚洲综合色欧美 | 99久久国产综合精品麻豆| 92精品国产成人观看免费| 色屁屁一区二区| 在线不卡免费欧美| 久久精品一区蜜桃臀影院| 一色桃子久久精品亚洲| 亚洲aⅴ怡春院| 久草这里只有精品视频| 国产河南妇女毛片精品久久久 | 国产高清在线精品| av电影在线观看一区| 欧美日韩国产综合久久| 欧美成人精品高清在线播放| 综合久久国产九一剧情麻豆| 丝袜美腿亚洲一区| 高清在线不卡av| 欧美日韩免费一区二区三区视频| 日韩欧美中文字幕公布| 亚洲欧洲日产国码二区| 日本va欧美va精品发布| 91视频.com| 精品少妇一区二区三区视频免付费| 亚洲丝袜另类动漫二区| 韩国女主播一区| 欧美日韩精品一区二区三区四区| 久久久久97国产精华液好用吗| 亚洲一区二三区| 国产不卡视频一区二区三区| 欧洲国内综合视频| 国产午夜精品在线观看| 日产国产欧美视频一区精品| 99久久亚洲一区二区三区青草| 日韩欧美123| 亚洲图片欧美视频| 高清不卡在线观看| 精品少妇一区二区三区日产乱码| 亚洲一区免费在线观看| 99久久精品免费看| 国产蜜臀av在线一区二区三区| 天堂在线一区二区| 91精品91久久久中77777| 中文字幕欧美日本乱码一线二线| 久久99热狠狠色一区二区| 欧美群妇大交群中文字幕| 亚洲色图制服诱惑| 国产成人自拍网| 精品国产乱码久久久久久图片| 午夜欧美在线一二页| 色呦呦网站一区| 亚洲免费观看高清| 成人手机电影网| 国产免费观看久久| 国产精品亚洲一区二区三区妖精| 欧美大片免费久久精品三p| 午夜欧美电影在线观看| 欧美日韩午夜在线视频| 亚洲综合丁香婷婷六月香| 91农村精品一区二区在线| 亚洲欧洲av另类| 色综合欧美在线视频区| 国产精品美女久久福利网站| 国产激情视频一区二区三区欧美|