ProfessionalCUDACProgramming
所属分类:GPU/显卡
开发工具:Cuda
文件大小:0KB
下载次数:0
上传日期:2020-07-13 03:38:40
上 传 者:
sh-1993
说明: 专业CUDA C编程,
(Professional CUDA C Programming,)
文件列表:
CodeSamples/ (0, 2020-07-12)
CodeSamples/chapter01/ (0, 2020-07-12)
CodeSamples/chapter01/Makefile (87, 2020-07-12)
CodeSamples/chapter01/hello.cu (422, 2020-07-12)
CodeSamples/chapter01/hello.md (444, 2020-07-12)
CodeSamples/chapter02/ (0, 2020-07-12)
CodeSamples/chapter02/Makefile (420, 2020-07-12)
CodeSamples/chapter02/checkDeviceInfor.cu (3847, 2020-07-12)
CodeSamples/chapter02/checkDeviceInfor.md (3880, 2020-07-12)
CodeSamples/chapter02/checkDimension.cu (1082, 2020-07-12)
CodeSamples/chapter02/checkDimension.md (1113, 2020-07-12)
CodeSamples/chapter02/checkThreadIndex.cu (2384, 2020-07-12)
CodeSamples/chapter02/checkThreadIndex.md (2417, 2020-07-12)
CodeSamples/chapter02/defineGridBlock.cu (955, 2020-07-12)
CodeSamples/chapter02/defineGridBlock.md (987, 2020-07-12)
CodeSamples/chapter02/sumArraysOnGPU-small-case.cu (3262, 2020-07-12)
CodeSamples/chapter02/sumArraysOnGPU-small-case.md (3304, 2020-07-12)
CodeSamples/chapter02/sumArraysOnGPU-timer.cu (3997, 2020-07-12)
CodeSamples/chapter02/sumArraysOnGPU-timer.md (4034, 2020-07-12)
CodeSamples/chapter02/sumArraysOnHost.c (988, 2020-07-12)
CodeSamples/chapter02/sumMatrixOnGPU-1D-grid-1D-block.cu (4264, 2020-07-12)
CodeSamples/chapter02/sumMatrixOnGPU-1D-grid-1D-block.md (4312, 2020-07-12)
CodeSamples/chapter02/sumMatrixOnGPU-2D-grid-1D-block.cu (4249, 2020-07-12)
CodeSamples/chapter02/sumMatrixOnGPU-2D-grid-1D-block.md (4297, 2020-07-12)
CodeSamples/chapter02/sumMatrixOnGPU-2D-grid-2D-block.cu (4321, 2020-07-12)
CodeSamples/chapter02/sumMatrixOnGPU-2D-grid-2D-block.md (4369, 2020-07-12)
CodeSamples/chapter02/sumMatrixOnGPU.cu (10244, 2020-07-12)
CodeSamples/chapter02/sumMatrixOnGPU.md (10275, 2020-07-12)
CodeSamples/chapter03/ (0, 2020-07-12)
CodeSamples/chapter03/Makefile (324, 2020-07-12)
CodeSamples/chapter03/nestedHelloWorld.cu (1361, 2020-07-12)
CodeSamples/chapter03/nestedHelloWorld.md (1394, 2020-07-12)
CodeSamples/chapter03/nestedReduce.cu (5687, 2020-07-12)
CodeSamples/chapter03/nestedReduce.md (5716, 2020-07-12)
CodeSamples/chapter03/nestedReduce2.cu (8430, 2020-07-12)
CodeSamples/chapter03/nestedReduce2.md (8460, 2020-07-12)
CodeSamples/chapter03/nestedReduceNosync.cu (7126, 2020-07-12)
CodeSamples/chapter03/nestedReduceNosync.md (7161, 2020-07-12)
CodeSamples/chapter03/reduceInteger.cu (20853, 2020-07-12)
... ...
# Professional CUDA C Programming
===============================
Included here are solution text and code for each chapter's exercises.
The text solutions for every chapter is included in ExerciseSolutions.pdf.
Each chapter also has its own code folder that includes sample .c and .cu
code solutions for any exercises which require them. The per-chapter code
folders each also include a Makefile that can be used to build the solutions
included.
The common/ directory contains common.h, which includes code that is common to
multiple chapters.
## Code Samples
* Chapter 01
* Chapter 02
* Chapter 03
* Chapter 04
* Chapter 05
* Chapter 06
* Chapter 07
* Chapter 08
* Chapter 09
* Chapter 10
**Common**
```c++
#include
#ifndef _COMMON_H
#define _COMMON_H
#define CHECK(call) \
{ \
const cudaError_t error = call; \
if (error != cudaSuccess) \
{ \
fprintf(stderr, "Error: %s:%d, ", __FILE__, __LINE__); \
fprintf(stderr, "code: %d, reason: %s\n", error, \
cudaGetErrorString(error)); \
exit(1); \
} \
}
#define CHECK_CUBLAS(call) \
{ \
cublasStatus_t err; \
if ((err = (call)) != CUBLAS_STATUS_SUCCESS) \
{ \
fprintf(stderr, "Got CUBLAS error %d at %s:%d\n", err, __FILE__, \
__LINE__); \
exit(1); \
} \
}
#define CHECK_CURAND(call) \
{ \
curandStatus_t err; \
if ((err = (call)) != CURAND_STATUS_SUCCESS) \
{ \
fprintf(stderr, "Got CURAND error %d at %s:%d\n", err, __FILE__, \
__LINE__); \
exit(1); \
} \
}
#define CHECK_CUFFT(call) \
{ \
cufftResult err; \
if ( (err = (call)) != CUFFT_SUCCESS) \
{ \
fprintf(stderr, "Got CUFFT error %d at %s:%d\n", err, __FILE__, \
__LINE__); \
exit(1); \
} \
}
#define CHECK_CUSPARSE(call) \
{ \
cusparseStatus_t err; \
if ((err = (call)) != CUSPARSE_STATUS_SUCCESS) \
{ \
fprintf(stderr, "Got error %d at %s:%d\n", err, __FILE__, __LINE__); \
cudaError_t cuda_err = cudaGetLastError(); \
if (cuda_err != cudaSuccess) \
{ \
fprintf(stderr, " CUDA error \"%s\" also detected\n", \
cudaGetErrorString(cuda_err)); \
} \
exit(1); \
} \
}
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);
}
#endif // _COMMON_H
```
## Solutions
* Chapter 02
* Chapter 03
* Chapter 04
* Chapter 05
* Chapter 06
* Chapter 07
* Chapter 08
* Chapter 09
近期下载者:
相关文件:
收藏者: