亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
在线一区二区三区四区五区| 精品第一国产综合精品aⅴ| 91精品国产综合久久精品app| 日韩视频在线你懂得| 亚洲欧洲成人精品av97| 国产在线不卡一区| 91麻豆精品久久久久蜜臀| 日韩一区在线看| 国产精品1区2区| 日韩免费观看高清完整版 | 久久久久久久久久美女| 亚洲狠狠爱一区二区三区| 懂色av中文一区二区三区| 欧美一二三区在线| 亚洲1区2区3区视频| 99视频精品在线| 国产日韩成人精品| 美女mm1313爽爽久久久蜜臀| 91久久精品一区二区| 国产精品剧情在线亚洲| 国产精品夜夜嗨| 欧美sm极限捆绑bd| 丝袜国产日韩另类美女| 在线观看免费视频综合| 亚洲免费大片在线观看| 97成人超碰视| 一区二区三区精品| 91在线看国产| 中文字幕欧美一区| 91免费视频观看| 亚洲男人的天堂av| 在线一区二区三区四区| 亚洲一区影音先锋| 精品视频一区三区九区| 婷婷一区二区三区| 欧美一级二级三级蜜桃| 免费人成在线不卡| 精品福利在线导航| 国产麻豆午夜三级精品| 国产视频一区二区在线观看| 高清不卡一二三区| 亚洲老妇xxxxxx| 欧美日韩国产三级| 免费国产亚洲视频| 久久综合999| 成人性生交大片免费看视频在线| 亚洲欧美成aⅴ人在线观看| 一本久久综合亚洲鲁鲁五月天| 亚洲一区二区在线视频| 91精品福利在线一区二区三区| 捆绑变态av一区二区三区| 国产色产综合色产在线视频| 99riav久久精品riav| 午夜国产精品影院在线观看| 精品av久久707| 99r国产精品| 麻豆一区二区99久久久久| 久久精品这里都是精品| 色综合天天性综合| 天天av天天翘天天综合网色鬼国产 | 国产亚洲欧美日韩日本| www.亚洲激情.com| 亚洲成人你懂的| 久久网站最新地址| 欧美综合一区二区| 精品影视av免费| 亚洲欧美一区二区久久 | 中文字幕第一区| 欧洲一区二区三区在线| 另类小说图片综合网| 亚洲视频免费观看| 日韩一区二区在线观看| 99精品视频在线观看| 麻豆国产91在线播放| 亚洲狼人国产精品| 国产亚洲欧美中文| 欧美一卡二卡三卡四卡| 国产91精品露脸国语对白| 亚洲va国产天堂va久久en| 亚洲国产高清aⅴ视频| 欧美精选一区二区| av综合在线播放| 免费观看成人鲁鲁鲁鲁鲁视频| 亚洲欧洲精品成人久久奇米网| 日韩一区二区电影在线| 色94色欧美sute亚洲线路一ni| 久久成人综合网| 午夜精品久久久久久久久久久| 国产色一区二区| 日韩美女在线视频| 欧美喷水一区二区| 91在线国内视频| 国产精品亚洲视频| 青青青伊人色综合久久| 一区二区三区欧美亚洲| 日韩毛片高清在线播放| 欧美精品一区二区三区久久久| 欧美老女人第四色| 色偷偷一区二区三区| 成人av在线电影| 国产剧情一区二区| 久久99精品国产.久久久久久| 亚洲成人免费视频| 亚洲一级电影视频| 一区二区三区免费在线观看| 亚洲欧洲日产国码二区| 亚洲欧美影音先锋| 亚洲国产精品精华液2区45| 久久精品亚洲麻豆av一区二区 | 夜夜嗨av一区二区三区网页 | 国产精品灌醉下药二区| 久久久亚洲精品石原莉奈| 欧美一级在线免费| 欧美一区二区播放| 91精品国产综合久久婷婷香蕉| 欧美亚洲免费在线一区| 在线观看不卡一区| 欧美精品18+| 91麻豆精品久久久久蜜臀| 欧美三级视频在线观看| 777午夜精品免费视频| 欧美一级二级三级蜜桃| 精品国产一区二区三区不卡| 精品久久久久久久人人人人传媒 | 欧美猛男gaygay网站| 欧美日韩一区高清| 欧美一区二区在线播放| 精品少妇一区二区三区| 国产亚洲一区二区三区四区| 国产精品九色蝌蚪自拍| 一区二区国产视频| 蜜桃视频免费观看一区| 精品一区二区三区视频在线观看| 国产91精品一区二区麻豆网站| 91美女片黄在线观看| 欧美少妇xxx| 精品免费一区二区三区| 中文字幕的久久| 性感美女久久精品| 蜜桃av噜噜一区| 成人sese在线| 欧美系列一区二区| 精品久久久久久久久久久院品网 | 中文字幕第一区二区| 亚洲精品美国一| 日韩av电影天堂| 成人av在线网| 欧美一级电影网站| 日本一区二区三区dvd视频在线| 一区二区在线观看视频在线观看| 日韩经典一区二区| 成人丝袜高跟foot| 欧美日韩mp4| 国产精品护士白丝一区av| 亚洲高清视频在线| 国产自产高清不卡| 91国产免费观看| 久久蜜桃av一区精品变态类天堂 | 一区二区三区四区蜜桃| 免费看欧美美女黄的网站| 成人app下载| 精品国产电影一区二区 | 亚洲欧美日韩国产综合在线| 美女视频免费一区| 91行情网站电视在线观看高清版| 欧美v亚洲v综合ⅴ国产v| 亚洲一区二区在线视频| 波多野结衣在线一区| 欧美一级高清大全免费观看| 亚洲精选视频在线| 国产jizzjizz一区二区| 日韩欧美专区在线| 亚洲精品国产a| 成人精品视频一区二区三区 | 欧美精品在线观看一区二区| 中文一区在线播放| 毛片不卡一区二区| 欧美军同video69gay| 成人欧美一区二区三区视频网页| 蜜臀a∨国产成人精品| 欧美性生活影院| 亚洲人精品一区| 播五月开心婷婷综合| 国产午夜精品一区二区三区视频 | 欧美精品一区二区三区很污很色的 | 大尺度一区二区| 精品国产sm最大网站免费看| 亚洲3atv精品一区二区三区| 91电影在线观看| 一区二区三区国产| 91美女在线视频| 一区二区三区影院| 91猫先生在线| 一区二区在线看| 欧洲视频一区二区| 亚洲自拍偷拍图区| 欧美性xxxxxx少妇| 亚洲综合视频网| 欧美日韩亚洲综合一区| 亚洲成a人v欧美综合天堂下载 |