亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产日产欧美精品一区二区三区| 亚洲午夜精品久久久久久久久| 欧美成人高清电影在线| 91精品国产入口| 制服.丝袜.亚洲.另类.中文| 欧美美女一区二区在线观看| 欧美日韩在线直播| 欧美一区二区三区免费视频| 中文字幕亚洲精品在线观看| 国产精品午夜久久| 国产精品国产三级国产三级人妇 | 中文字幕不卡在线观看| 国产丝袜在线精品| 国产精品免费久久| 亚洲日穴在线视频| 亚洲成人福利片| 麻豆精品在线观看| 国产麻豆欧美日韩一区| 成+人+亚洲+综合天堂| 91亚洲永久精品| 欧美影院午夜播放| 91精品国产高清一区二区三区| 日韩视频免费直播| 亚洲国产精品传媒在线观看| 中文字幕日韩欧美一区二区三区| 一区二区三区四区国产精品| 视频在线观看一区| 国产精品综合视频| 99精品国产一区二区三区不卡| 欧美最猛性xxxxx直播| 91精品欧美综合在线观看最新| 日韩欧美中文字幕一区| 久久久久青草大香线综合精品| 国产精品沙发午睡系列990531| 亚洲手机成人高清视频| 丝袜亚洲另类丝袜在线| 国内精品久久久久影院一蜜桃| 国产精品一二三区在线| 色狠狠一区二区三区香蕉| 欧美一区二区播放| 国产精品免费丝袜| 丝袜亚洲另类丝袜在线| 粉嫩绯色av一区二区在线观看| 欧美性xxxxxx少妇| 久久九九久精品国产免费直播| 亚洲欧美日韩电影| 国模冰冰炮一区二区| 在线影院国内精品| 久久综合精品国产一区二区三区| 亚洲色图在线视频| 国产在线精品不卡| 欧美亚洲一区三区| 国产欧美一区二区三区在线老狼 | 色综合天天做天天爱| 日韩欧美中文字幕制服| 一区二区日韩电影| 国产成人免费视频一区| 欧美日韩国产片| 国产精品久久综合| 韩国v欧美v日本v亚洲v| 欧美日韩1234| 亚洲欧美一区二区三区极速播放| 青青草成人在线观看| 99r精品视频| 精品国产123| 三级一区在线视频先锋| 99国产精品久久久| 国产亚洲美州欧州综合国| 日韩av一二三| 欧美视频一区在线| 亚洲男人电影天堂| 粉嫩av一区二区三区| 日韩你懂的电影在线观看| 亚洲一区二区三区在线| 不卡av电影在线播放| 亚洲精品在线电影| 日韩黄色小视频| 精品视频在线免费观看| 亚洲精品伦理在线| 成人av在线播放网址| 国产亚洲欧美在线| 精品亚洲欧美一区| 日韩一区二区三区三四区视频在线观看| 亚洲天堂久久久久久久| 成人免费看的视频| 国产三级三级三级精品8ⅰ区| 免费在线观看一区| 777奇米四色成人影色区| 亚洲国产裸拍裸体视频在线观看乱了| 成人精品鲁一区一区二区| 久久久久97国产精华液好用吗 | 日韩一区和二区| 亚洲一区二区三区在线| 欧美亚洲动漫制服丝袜| 一区二区三区四区视频精品免费 | 国产精品美女久久久久aⅴ国产馆| 免费成人你懂的| 日韩亚洲欧美在线| 日本女人一区二区三区| 91精品国产综合久久精品图片| 午夜视频一区二区| 91麻豆精品国产91久久久| 日韩专区中文字幕一区二区| 欧美日韩综合一区| 日韩不卡一区二区| 欧美一区二区三区性视频| 日本视频免费一区| 欧美成人a在线| 国产一二三精品| 国产视频不卡一区| 99久久伊人网影院| 一区二区理论电影在线观看| 欧洲视频一区二区| 日韩av网站在线观看| 精品国产乱码久久久久久牛牛 | 欧美性色综合网| 亚洲高清免费视频| 欧美一区二区视频在线观看2020| 日本中文字幕一区二区视频 | 亚洲成av人片| 欧美大片免费久久精品三p| 国产曰批免费观看久久久| 国产网站一区二区| 99re6这里只有精品视频在线观看| 亚洲欧洲美洲综合色网| 91在线一区二区| 亚洲国产精品久久不卡毛片| 欧美一卡2卡3卡4卡| 国产99精品国产| 亚洲伊人伊色伊影伊综合网| 欧美精品在线观看一区二区| 极品少妇xxxx精品少妇| 亚洲国产精华液网站w| 91黄色免费观看| 麻豆专区一区二区三区四区五区| 国产日韩欧美不卡| 在线观看欧美日本| 免费精品视频在线| 中文字幕中文字幕一区| 欧美日韩国产一区二区三区地区| 久久99精品国产| 亚洲日本va在线观看| 日韩一区二区在线免费观看| 国产老肥熟一区二区三区| 一级做a爱片久久| 精品国产网站在线观看| 色偷偷成人一区二区三区91| 免费成人你懂的| 亚洲欧洲国产日韩| 日韩视频永久免费| 91美女蜜桃在线| 久久国产精品免费| 亚洲美女偷拍久久| 337p日本欧洲亚洲大胆精品| 一本色道综合亚洲| 国产一区二区三区香蕉| 亚洲综合一区在线| 欧美韩日一区二区三区四区| 欧美精品久久99久久在免费线| 国产成人精品一区二区三区四区| 亚洲午夜在线电影| 久久久美女毛片| 欧美日韩精品欧美日韩精品| 成人午夜在线播放| 青草国产精品久久久久久| 亚洲免费大片在线观看| 国产亚洲1区2区3区| 91精品国模一区二区三区| 91在线你懂得| 国产精品18久久久久| 日本成人中文字幕在线视频| 1区2区3区国产精品| 久久久精品影视| 日韩一区二区三区视频在线| 精品视频一区 二区 三区| 91片在线免费观看| 国产成人av电影在线观看| 精品一区二区三区视频在线观看| 亚洲男人天堂一区| 中文字幕av不卡| 久久色视频免费观看| 欧美一区二区三区公司| 精品视频色一区| 欧美无人高清视频在线观看| 成人av在线看| 成人一级黄色片| 国产一区二区三区美女| 麻豆成人免费电影| 日韩高清欧美激情| 亚洲成人第一页| 亚洲动漫第一页| 亚洲一区在线看| 一区二区三区 在线观看视频| 亚洲视频一二三区| 国产精品久久精品日日| 国产日韩欧美精品综合| 国产欧美一区二区三区在线老狼| 久久久久久久久蜜桃| 久久综合久久99| 久久精品一级爱片|