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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? marsutils.cu

?? GPU實(shí)現(xiàn)的MapReduce framework,對(duì)于學(xué)習(xí)并行編程和cuda平臺(tái)的編程方面有著極好的參考價(jià)值
?? CU
?? 第 1 頁 / 共 3 頁
字號(hào):
/**
 *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;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合一区二区精品导航| 狠狠色综合日日| 国产欧美一区二区三区鸳鸯浴| 欧美美女黄视频| 91在线观看一区二区| 国产精品99久| 精品无人码麻豆乱码1区2区| 午夜视频一区二区三区| 亚洲欧美福利一区二区| 国产精品色在线观看| 日韩欧美在线网站| 91精品在线免费| 欧美日韩激情一区二区| 91福利资源站| 欧美亚洲日本国产| www.日韩av| 91丨九色丨国产丨porny| 岛国精品在线播放| 日本久久一区二区三区| 在线视频一区二区免费| 欧美日韩高清一区二区| 欧美videossexotv100| 日韩一区二区三区在线| 欧美成人一级视频| 精品国产麻豆免费人成网站| 精品欧美久久久| 欧美情侣在线播放| 色综合咪咪久久| 欧美性生活一区| 欧美丰满美乳xxx高潮www| 欧美日本在线观看| 日韩欧美国产综合在线一区二区三区| 欧美日韩大陆在线| 欧美tk—视频vk| 欧美一级久久久| 欧美mv日韩mv亚洲| 欧美国产精品中文字幕| 中文字幕一区av| 亚洲午夜电影在线| 免费观看在线综合色| 久久99热狠狠色一区二区| 国产一区二区免费看| 成人免费视频视频| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 国产精品精品国产色婷婷| 欧美韩国日本不卡| 一区二区三区在线看| 天堂蜜桃91精品| 国产乱码字幕精品高清av | 在线成人高清不卡| 久久一日本道色综合| 国产精品久久久久久亚洲伦| 亚洲欧美另类小说| 日韩福利电影在线| 日韩成人免费在线| 风流少妇一区二区| 欧美在线三级电影| 日韩欧美自拍偷拍| 中文字幕制服丝袜成人av| 亚洲在线视频网站| 国产乱码一区二区三区| 色94色欧美sute亚洲13| 日韩精品一区二区三区视频播放| 欧美激情自拍偷拍| 亚洲天堂免费看| 久99久精品视频免费观看| 99视频有精品| 日韩欧美国产精品| 亚洲乱码精品一二三四区日韩在线| 秋霞电影一区二区| 91麻豆国产在线观看| 91麻豆精品国产91久久久久久| 久久久久99精品国产片| 亚洲午夜久久久久| 大胆欧美人体老妇| 欧美午夜片在线看| 中文一区一区三区高中清不卡| 亚洲成国产人片在线观看| 国产乱国产乱300精品| 欧美精品在线观看一区二区| 欧美一级久久久久久久大片| 无吗不卡中文字幕| 成人午夜视频网站| 日韩西西人体444www| 亚洲美女免费在线| 国产精品一区二区视频| 91精品国产91久久久久久一区二区| 国产精品私房写真福利视频| 蜜臀av一区二区三区| 99久久精品一区| 久久久久成人黄色影片| 免费看欧美美女黄的网站| 色综合一区二区| 国产欧美日韩亚州综合| 久草中文综合在线| 宅男噜噜噜66一区二区66| 亚洲精品一二三| 成人黄色小视频在线观看| 精品免费日韩av| 日韩二区三区在线观看| 欧美性猛交一区二区三区精品| 久久久99精品免费观看不卡| 久久福利视频一区二区| 欧美高清你懂得| 亚洲国产欧美在线| 色婷婷精品久久二区二区蜜臂av| 久久亚洲精品小早川怜子| 天堂在线一区二区| 欧美理论电影在线| 亚洲一区影音先锋| 欧美性感一类影片在线播放| 亚洲人妖av一区二区| 久久精品国产秦先生| 国产99久久久精品| 久久久精品日韩欧美| 成人夜色视频网站在线观看| 中文字幕+乱码+中文字幕一区| 播五月开心婷婷综合| 亚洲日穴在线视频| 欧美唯美清纯偷拍| 日本伊人色综合网| 精品国产伦一区二区三区观看体验| 韩国女主播一区| 国产人成一区二区三区影院| 97久久人人超碰| 樱桃国产成人精品视频| 欧洲在线/亚洲| 美国三级日本三级久久99| 日韩三级av在线播放| 成人综合婷婷国产精品久久| 亚洲欧洲国产日韩| 欧美日韩国产综合一区二区| 久久精品999| 中文字幕一区日韩精品欧美| 在线视频国内一区二区| 蜜芽一区二区三区| 久久色视频免费观看| 成人国产精品免费| 亚洲二区在线观看| 久久综合久久鬼色中文字| 99精品视频在线观看免费| 丝袜亚洲精品中文字幕一区| 日韩欧美中文一区| 成人性色生活片| 视频在线观看国产精品| 国产欧美一区二区精品秋霞影院 | 国产美女在线精品| 自拍偷拍亚洲欧美日韩| 欧美一卡二卡三卡四卡| 国产iv一区二区三区| 亚洲一区二区精品视频| 国产亚洲欧美一级| 欧美在线观看一二区| 国产一区日韩二区欧美三区| 一区二区三区成人| 欧美精品一区二区蜜臀亚洲| 色天天综合久久久久综合片| 国产在线一区观看| 一级特黄大欧美久久久| 国产午夜精品一区二区三区视频 | 欧美吞精做爰啪啪高潮| 国产一区二区美女| 丝袜亚洲另类丝袜在线| 中文字幕欧美一| 久久免费偷拍视频| 欧美精品777| 99久久777色| 国产在线精品不卡| 婷婷成人激情在线网| 蜜臀av性久久久久av蜜臀妖精| 成人免费小视频| 337p粉嫩大胆色噜噜噜噜亚洲| 97久久久精品综合88久久| 国内成人免费视频| 日韩av电影一区| 亚洲尤物视频在线| 国产精品久久毛片a| 精品处破学生在线二十三| 欧美日本韩国一区二区三区视频 | 在线欧美小视频| 成人免费视频国产在线观看| 韩国精品久久久| 日本中文字幕一区二区视频 | 日本美女一区二区三区| 亚洲欧美一区二区三区久本道91| 国产性做久久久久久| 欧美videossexotv100| 欧美日韩国产综合视频在线观看| 91免费版在线看| 成人v精品蜜桃久久一区| 国产自产高清不卡| 久久99久久久久| 男女男精品网站| 日本午夜精品视频在线观看| 亚洲一区二区偷拍精品| 亚洲欧洲日韩在线| 最近日韩中文字幕| 国产精品成人一区二区艾草| 日本一区二区免费在线| 国产欧美日韩三区|