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

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

?? marsutils.cu

?? GPU實現(xiàn)的MapReduce framework,對于學(xué)習(xí)并行編程和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;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
www.欧美色图| 欧日韩精品视频| 日韩理论在线观看| 欧美色图一区二区三区| 日韩精品每日更新| 中文字幕av一区 二区| 欧美午夜精品久久久| 国产白丝精品91爽爽久久| 亚洲精品乱码久久久久久黑人| 欧美高清视频在线高清观看mv色露露十八 | 久久精品这里都是精品| 色偷偷88欧美精品久久久| 蜜臀av一区二区在线观看| 97se亚洲国产综合自在线观| 欧美一区二区三区日韩视频| 亚洲精品视频一区| 国产一区二区三区综合| 51精品久久久久久久蜜臀| 一区二区三区免费网站| 大陆成人av片| 中文字幕乱码日本亚洲一区二区| 蜜桃久久精品一区二区| 日韩亚洲电影在线| 大陆成人av片| 麻豆精品国产传媒mv男同| 日韩理论片网站| 国产视频一区在线观看| 91精品国产综合久久久久久漫画| av亚洲精华国产精华精华| 国产精品网站导航| 青青草国产精品97视觉盛宴| 亚洲18影院在线观看| 欧美亚日韩国产aⅴ精品中极品| 精品对白一区国产伦| 国产精品一级片在线观看| 国产日韩视频一区二区三区| 国产不卡免费视频| 一区2区3区在线看| 91精品国产综合久久久久久久| 蜜桃免费网站一区二区三区| 国产午夜精品福利| 91色porny在线视频| 亚洲一区二区三区四区五区中文| 欧美色男人天堂| 91毛片在线观看| 国产精品系列在线| 国产老妇另类xxxxx| 亚洲免费观看高清在线观看| 国产精品久久综合| 亚洲综合男人的天堂| 一区二区三区波多野结衣在线观看| eeuss鲁一区二区三区| 精品一区二区三区在线播放| 美女免费视频一区| 男男视频亚洲欧美| 国产一区二区精品久久| 韩国三级在线一区| 成人精品gif动图一区| 国产一区二区在线看| 亚洲美女视频一区| wwwwxxxxx欧美| 欧美色爱综合网| 日本不卡中文字幕| 亚洲一区免费观看| 国产精品毛片大码女人| 日韩色在线观看| 欧美综合一区二区| 久久久国产精华| 暴力调教一区二区三区| 91精品办公室少妇高潮对白| 91在线看国产| 精品裸体舞一区二区三区| 日韩精品中文字幕一区 | 国产精品一线二线三线| 国产在线乱码一区二区三区| 成人黄色av电影| 色悠久久久久综合欧美99| 欧美一区二区成人6969| 久久久91精品国产一区二区三区| 国产欧美一区二区精品仙草咪| 亚洲女厕所小便bbb| 香蕉久久一区二区不卡无毒影院| 99天天综合性| 欧美日本韩国一区二区三区视频| 国产成人精品www牛牛影视| 欧美在线综合视频| 7777精品伊人久久久大香线蕉最新版| 国产精品久久久久久亚洲毛片 | 亚洲免费观看高清完整版在线观看熊| 91福利视频在线| 欧美在线观看一区| 欧美大片一区二区三区| 久久影院电视剧免费观看| 中文字幕字幕中文在线中不卡视频| 国产成人精品一区二| 99久久精品国产麻豆演员表| 欧美日本在线观看| 国产日韩欧美a| 亚洲伊人色欲综合网| 亚洲妇熟xx妇色黄| 日本视频中文字幕一区二区三区| 青青草国产精品97视觉盛宴| 成人亚洲一区二区一| 欧美视频一区在线| 国产亚洲精品超碰| 亚洲国产日韩a在线播放性色| 亚洲综合在线视频| 国产综合色在线视频区| 在线观看网站黄不卡| 久久亚洲一级片| 日韩黄色免费电影| 94-欧美-setu| 精品国免费一区二区三区| 亚洲一区二区三区在线| 久久国产精品99精品国产| 亚洲成人一区在线| 成人激情免费网站| 久久青草欧美一区二区三区| 奇米精品一区二区三区四区| 欧美一卡二卡在线| 国产精品综合av一区二区国产馆| 亚洲视频一区二区在线观看| 国产精品家庭影院| 精久久久久久久久久久| 欧美老肥妇做.爰bbww| 在线视频综合导航| 99精品欧美一区二区蜜桃免费 | 色av一区二区| 久久精品夜夜夜夜久久| 日韩精品一二三四| 欧美日韩日日骚| 国产精品综合av一区二区国产馆| 首页综合国产亚洲丝袜| 欧美艳星brazzers| 午夜久久福利影院| 欧美激情在线一区二区三区| 欧美中文字幕一区二区三区| 成人欧美一区二区三区1314 | 国产婷婷一区二区| 国产精品自拍毛片| 韩国精品久久久| 国产乱子伦一区二区三区国色天香| 国产主播一区二区三区| 国产精品性做久久久久久| 国产91精品欧美| 色欧美片视频在线观看| 欧美三级欧美一级| 精品日韩一区二区三区免费视频| 天堂一区二区在线| 成人av网在线| 亚洲综合视频网| 亚洲国产精品视频| 日韩精彩视频在线观看| 玖玖九九国产精品| 国产精品资源站在线| yourporn久久国产精品| 97精品久久久久中文字幕| 欧美精品vⅰdeose4hd| av电影在线不卡| 91一区在线观看| 欧美一级片在线看| 亚洲欧洲美洲综合色网| 国产欧美一区二区三区鸳鸯浴 | 亚洲天堂av一区| 图片区小说区区亚洲影院| 国产乱子伦一区二区三区国色天香 | 国产精品久久毛片av大全日韩| 一区二区三区成人| 成人午夜电影小说| 欧美一级黄色片| 夜夜揉揉日日人人青青一国产精品 | 夜夜夜精品看看| 国产精品1区二区.| 欧美刺激午夜性久久久久久久| 亚洲色图欧美偷拍| 国产精品一级片| 精品欧美一区二区在线观看| 国产午夜三级一区二区三| 欧美乱熟臀69xxxxxx| 欧美丝袜自拍制服另类| 在线观看91视频| 一本到一区二区三区| 色婷婷综合久久久中文一区二区| 欧美在线免费视屏| 欧美成人高清电影在线| 亚洲免费在线视频一区 二区| 国产一区二区三区免费观看| 欧美国产一区视频在线观看| 91尤物视频在线观看| 丝袜美腿高跟呻吟高潮一区| 久久久国产精品不卡| 欧美在线你懂的| 日韩电影一区二区三区| 加勒比av一区二区| 99久精品国产| 国产三级一区二区| 国产亚洲精品超碰| 成人欧美一区二区三区小说| 亚洲精品国久久99热| 极品尤物av久久免费看|