亚洲欧美第一页_禁久久精品乱码_粉嫩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噜噜一区二区三区av| 欧美日韩电影在线| 亚洲欧美中日韩| 国产精品自拍在线| 日韩一区二区三区三四区视频在线观看 | 亚洲色图在线视频| 国精产品一区一区三区mba桃花 | 欧美日韩中文字幕精品| 国产精品欧美综合在线| 国产乱一区二区| 日韩一级成人av| 日韩中文字幕亚洲一区二区va在线| 91视频在线看| 亚洲欧美成aⅴ人在线观看 | 亚洲日本va午夜在线电影| 懂色av一区二区三区蜜臀| 国产亚洲欧美日韩在线一区| 精品一区二区三区免费视频| 欧美一区二区三区在线观看视频| 亚洲1区2区3区4区| 666欧美在线视频| 日本午夜精品视频在线观看| 欧美一级在线免费| 另类的小说在线视频另类成人小视频在线| 欧美人妇做爰xxxⅹ性高电影 | 国产一区二区三区四区五区美女 | 麻豆极品一区二区三区| 欧美一区二区视频在线观看2022 | 久久精工是国产品牌吗| 日韩一区二区在线看片| 久久国产精品99精品国产| 精品欧美一区二区三区精品久久| 精东粉嫩av免费一区二区三区| 精品欧美一区二区久久| 国产xxx精品视频大全| 国产精品三级视频| 91久久一区二区| 亚洲超碰精品一区二区| 日韩午夜激情电影| 国产精品99久久久久久有的能看 | 久久精品一二三| av亚洲精华国产精华| 一区二区国产视频| 欧美一区二区三区视频| 国产传媒欧美日韩成人| **性色生活片久久毛片| 欧美剧在线免费观看网站| 美脚の诱脚舐め脚责91 | 91麻豆免费看| 肉肉av福利一精品导航| 久久久久久久久99精品| 91视频在线观看| 久久精品99国产精品日本| 亚洲欧美综合另类在线卡通| 欧美日韩一区在线观看| 国产盗摄女厕一区二区三区 | 国产美女娇喘av呻吟久久| 国产精品美女久久福利网站| 欧美性受xxxx黑人xyx性爽| 韩国欧美一区二区| 亚洲一区视频在线观看视频| 欧美不卡123| 欧美午夜精品一区二区蜜桃| 激情五月激情综合网| 一区二区三区日韩精品| 亚洲精品在线网站| 在线观看视频一区| 国产精品66部| 手机精品视频在线观看| 国产精品国产a| 2023国产精华国产精品| 91福利在线看| 国产成a人亚洲精品| 五月婷婷久久丁香| 国产精品灌醉下药二区| www国产精品av| 欧美一区二区视频免费观看| 91在线视频播放| 国产精品亚洲一区二区三区妖精| 丝袜国产日韩另类美女| 伊人色综合久久天天| 欧美高清在线一区| 精品免费国产二区三区| 欧美精品一二三四| 欧美三级中文字| 99精品欧美一区二区三区小说| 韩国三级在线一区| 久久99在线观看| 日韩高清在线一区| 亚洲成人综合在线| 一区二区三区欧美激情| 国产精品理论片在线观看| 久久色在线视频| 久久嫩草精品久久久久| 欧美成人精品二区三区99精品| 欧美久久一二三四区| 欧美主播一区二区三区| 一本色道久久综合亚洲aⅴ蜜桃| 福利一区二区在线观看| 国产精品性做久久久久久| 国产一区二区三区免费看 | 中文字幕在线免费不卡| 久久久不卡网国产精品一区| 欧美精品一区二区三区蜜桃 | 亚洲福利视频一区| 亚洲va国产天堂va久久en| 亚洲综合色成人| 亚洲网友自拍偷拍| 婷婷中文字幕综合| 天堂一区二区在线| 免费成人av资源网| 日韩av电影免费观看高清完整版 | 一区二区在线观看免费视频播放| 日韩理论在线观看| 亚洲天堂精品视频| 亚洲综合激情小说| 午夜视频一区二区| 美洲天堂一区二卡三卡四卡视频| 午夜视频在线观看一区| 精品一区二区三区蜜桃| 国产精品主播直播| 99综合影院在线| 欧美色视频在线观看| 51午夜精品国产| 国产视频在线观看一区二区三区 | 国产清纯白嫩初高生在线观看91 | 欧美视频一二三区| 中文字幕不卡一区| 欧美一二区视频| 欧美一区二区三区免费在线看| 在线看日韩精品电影| 成人性生交大片免费看视频在线| 日韩精品每日更新| 日韩av电影免费观看高清完整版| 亚洲成人综合视频| 国模无码大尺度一区二区三区| 另类小说综合欧美亚洲| 亚洲色欲色欲www在线观看| 亚洲人成在线播放网站岛国| 日韩午夜在线观看| 国产精品久线观看视频| 天天av天天翘天天综合网色鬼国产| 老司机免费视频一区二区 | 美女国产一区二区| 99久久亚洲一区二区三区青草| 精品视频999| 国产精品伦一区| 全国精品久久少妇| 91首页免费视频| 欧美一二三四区在线| 亚洲免费观看高清| 国产一区二区精品久久| 欧美日韩精品一区二区天天拍小说 | 日韩一级黄色片| 亚洲精选视频在线| 国产精品1区2区3区| 777亚洲妇女| 一区二区三区中文在线| 国产福利一区在线观看| 欧美一区二区三区视频在线| 依依成人综合视频| 91麻豆国产自产在线观看| 久久久精品tv| 久久超碰97中文字幕| 欧美日韩免费不卡视频一区二区三区| 国产日产亚洲精品系列| 久久精品99久久久| 51精品国自产在线| 亚洲一区二区三区四区中文字幕| 粉嫩蜜臀av国产精品网站| 欧美一区二区三区电影| 亚洲福利一区二区三区| 欧美在线一区二区| 亚洲精品欧美在线| 91麻豆国产精品久久| 国产精品美女久久久久久久久| 国产成人自拍网| 26uuu另类欧美| 精品一区二区三区在线播放视频| 欧美日韩免费电影| 亚洲成人av在线电影| 欧美性色aⅴ视频一区日韩精品| 中文字幕一区二区三| 成人动漫在线一区| 亚洲国产精品二十页| 国产不卡在线播放| 国产日产欧美一区二区三区| 国产在线国偷精品产拍免费yy| 精品欧美一区二区久久| 激情丁香综合五月| 久久久高清一区二区三区|