資源簡介
cuda 權威指南習題答案pdf,以及在Linux code!!!!

代碼片段和文件信息
#include?
#include?
#include?
inline?double?seconds()
{
????struct?timeval?tp;
????struct?timezone?tzp;
????int?i?=?gettimeofday(&tp?&tzp);
????return?((double)tp.tv_sec?+?(double)tp.tv_usec?*?1.e-6);
}
//?Recursive?Implementation?of?Interleaved?Pair?Approach
float?recursiveReduce(float?*data?int?const?size)
{
????//?terminate?check
????if?(size?==?1)?return?data[0];
????//?renew?the?stride
????int?const?stride?=?size?/?2;
????//?in-place?reduction
????for?(int?i?=?0;?i?????{
????????data[i]?+=?data[i?+?stride];
????}
????//?call?recursively
????return?recursiveReduce(data?stride);
}
int?main(int?argc?char?**argv)
{
????//?initialization
????int?size?=?1?<24;?//?total?number?of?elements?to?reduce
????printf(“%s?starting?reduction?with?array?size?%d\n“?argv[0]?size);
????//?execution?configuration
????int?blocksize?=?512;???//?initial?block?size
????if(argc?>?1)
????{
????????blocksize?=?atoi(argv[1]);???//?block?size?from?command?line?argument
????}
????//?allocate?host?memory
????size_t?bytes?=?size?*?sizeof(float);
????float?*h_idata?=?(float?*)?malloc(bytes);
????//?initialize?the?array
????for?(int?i?=?0;?i?????{
????????h_idata[i]?=?(float)(rand()?&?0xFF);
????}
????//?cpu?reduction
????double?iStart?=?seconds();
????int?cpu_sum?=?recursiveReduce?(h_idata?size);
????double?iElaps?=?seconds()?-?iStart;
????printf(“cpu?reduce?elapsed?%f?sec?cpu_sum:?%d\n“?iElaps?cpu_sum);
????//?free?host?memory
????free(h_idata);
????return?EXIT_SUCCESS;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-07-08?03:02??Solutions\
?????文件????????6148??2014-07-07?20:01??Solutions\.DS_Store
?????目錄???????????0??2014-06-22?07:22??Solutions\chapter02\
?????文件?????????232??2014-06-22?07:22??Solutions\chapter02\Makefile
?????文件????????4545??2014-06-22?07:22??Solutions\chapter02\sumMatrixOnGPU-2D-grid-1D-block-two.cu
?????文件????????4231??2014-06-22?07:22??Solutions\chapter02\sumMatrixOnGPU-2D-grid-2D-block-integer.cu
?????目錄???????????0??2014-07-06?09:26??Solutions\chapter03\
?????文件?????????576??2014-07-05?06:28??Solutions\chapter03\Makefile
?????文件????????1410??2014-06-23?14:57??Solutions\chapter03\nestedHelloWorldLimited.cu
?????文件????????1354??2014-06-23?14:57??Solutions\chapter03\nestedHelloWorldNew.cu
?????文件????????1552??2014-06-23?14:57??Solutions\chapter03\reduceFloat.c
?????文件????????9853??2014-06-23?14:57??Solutions\chapter03\reduceFloatGpu.cu
?????文件???????23598??2014-07-04?22:09??Solutions\chapter03\reduceInteger-16.cu
?????文件???????24935??2014-07-05?07:17??Solutions\chapter03\reduceInteger-8-new.cu
?????文件???????10531??2014-07-06?09:26??Solutions\chapter03\reduceInteger-sync.cu
?????目錄???????????0??2014-07-06?20:27??Solutions\chapter04\
?????文件????????1236??2014-06-23?14:57??Solutions\chapter04\globalVariable1.cu
?????文件????????1053??2014-06-23?14:57??Solutions\chapter04\globalVariable2.cu
?????文件?????????368??2014-07-06?20:27??Solutions\chapter04\Makefile
?????文件????????1607??2014-07-04?22:09??Solutions\chapter04\memTransfer.cu
?????文件????????1908??2014-07-04?22:09??Solutions\chapter04\pinMemTransfer.cu
?????文件????????4215??2014-06-25?00:06??Solutions\chapter04\readWriteSegment.cu
?????文件????????4012??2014-06-25?00:06??Solutions\chapter04\readWriteSegmentUnroll.cu
?????文件????????4467??2014-07-06?09:26??Solutions\chapter04\simpleMathAoS-align.cu
?????文件????????4279??2014-07-06?20:27??Solutions\chapter04\simpleMathAoS-x.cu
?????文件????????4987??2014-07-06?09:26??Solutions\chapter04\sumArrayZerocpy-offset.cu
?????文件????????5594??2014-07-06?09:26??Solutions\chapter04\sumArrayZerocpyUVA-offset.cu
?????文件????????6148??2014-06-25?08:35??Solutions\chapter04\sumArrayZerocpyUVA.cu
?????文件???????14296??2014-06-25?05:58??Solutions\chapter04\transpose.cu
?????目錄???????????0??2014-06-29?18:35??Solutions\chapter05\
?????文件????????8978??2014-06-25?23:07??Solutions\chapter05\checkSmemRectangle.cu
............此處省略31個文件信息
- 上一篇:計算機網絡課程設計----模擬Ethernet幀發送
- 下一篇:多元統計分析統計論文
評論
共有 條評論