2015-01-27 09:46:40 +08:00
|
|
|
#define EIGEN_USE_GPU
|
|
|
|
|
|
|
|
#include <cuda.h>
|
|
|
|
#include <cuda_runtime.h>
|
|
|
|
#include <iostream>
|
|
|
|
|
2016-01-29 02:35:14 +08:00
|
|
|
#include "tensor_benchmarks.h"
|
2015-01-27 09:46:40 +08:00
|
|
|
|
|
|
|
// Simple functions
|
|
|
|
#define BM_FuncGPU(FUNC) \
|
|
|
|
static void BM_##FUNC(int iters, int N) { \
|
|
|
|
StopBenchmarkTiming(); \
|
2016-01-29 03:11:45 +08:00
|
|
|
Eigen::CudaStreamDevice stream; \
|
2015-01-27 09:46:40 +08:00
|
|
|
Eigen::GpuDevice device(&stream); \
|
2016-02-23 13:28:02 +08:00
|
|
|
BenchmarkSuite<Eigen::GpuDevice, float> suite(device, N); \
|
2015-01-27 09:46:40 +08:00
|
|
|
cudaDeviceSynchronize(); \
|
|
|
|
suite.FUNC(iters); \
|
|
|
|
} \
|
|
|
|
BENCHMARK_RANGE(BM_##FUNC, 10, 5000);
|
|
|
|
|
|
|
|
BM_FuncGPU(memcpy);
|
2016-01-29 08:20:36 +08:00
|
|
|
BM_FuncGPU(typeCasting);
|
2015-01-27 09:46:40 +08:00
|
|
|
BM_FuncGPU(random);
|
|
|
|
BM_FuncGPU(slicing);
|
2016-01-31 02:20:43 +08:00
|
|
|
BM_FuncGPU(rowChip);
|
|
|
|
BM_FuncGPU(colChip);
|
2015-01-27 09:46:40 +08:00
|
|
|
BM_FuncGPU(shuffling);
|
|
|
|
BM_FuncGPU(padding);
|
|
|
|
BM_FuncGPU(striding);
|
|
|
|
BM_FuncGPU(broadcasting);
|
|
|
|
BM_FuncGPU(coeffWiseOp);
|
2016-01-29 08:20:36 +08:00
|
|
|
BM_FuncGPU(algebraicFunc);
|
|
|
|
BM_FuncGPU(transcendentalFunc);
|
|
|
|
BM_FuncGPU(rowReduction);
|
|
|
|
BM_FuncGPU(colReduction);
|
2016-03-01 06:57:52 +08:00
|
|
|
BM_FuncGPU(fullReduction);
|
2015-01-27 09:46:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
// Contractions
|
|
|
|
#define BM_FuncWithInputDimsGPU(FUNC, D1, D2, D3) \
|
|
|
|
static void BM_##FUNC##_##D1##x##D2##x##D3(int iters, int N) { \
|
|
|
|
StopBenchmarkTiming(); \
|
2016-01-29 03:11:45 +08:00
|
|
|
Eigen::CudaStreamDevice stream; \
|
2015-01-27 09:46:40 +08:00
|
|
|
Eigen::GpuDevice device(&stream); \
|
2016-02-23 13:28:02 +08:00
|
|
|
BenchmarkSuite<Eigen::GpuDevice, float> suite(device, D1, D2, D3); \
|
2015-01-27 09:46:40 +08:00
|
|
|
cudaDeviceSynchronize(); \
|
|
|
|
suite.FUNC(iters); \
|
|
|
|
} \
|
|
|
|
BENCHMARK_RANGE(BM_##FUNC##_##D1##x##D2##x##D3, 10, 5000);
|
|
|
|
|
|
|
|
|
|
|
|
BM_FuncWithInputDimsGPU(contraction, N, N, N);
|
|
|
|
BM_FuncWithInputDimsGPU(contraction, 64, N, N);
|
|
|
|
BM_FuncWithInputDimsGPU(contraction, N, 64, N);
|
2016-01-29 08:20:36 +08:00
|
|
|
BM_FuncWithInputDimsGPU(contraction, N, N, 64);
|
2015-01-27 09:46:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
// Convolutions
|
|
|
|
#define BM_FuncWithKernelDimsGPU(FUNC, DIM1, DIM2) \
|
|
|
|
static void BM_##FUNC##_##DIM1##x##DIM2(int iters, int N) { \
|
|
|
|
StopBenchmarkTiming(); \
|
2016-01-29 03:11:45 +08:00
|
|
|
Eigen::CudaStreamDevice stream; \
|
2015-01-27 09:46:40 +08:00
|
|
|
Eigen::GpuDevice device(&stream); \
|
2016-02-23 13:28:02 +08:00
|
|
|
BenchmarkSuite<Eigen::GpuDevice, float> suite(device, N); \
|
2015-01-27 09:46:40 +08:00
|
|
|
cudaDeviceSynchronize(); \
|
|
|
|
suite.FUNC(iters, DIM1, DIM2); \
|
|
|
|
} \
|
|
|
|
BENCHMARK_RANGE(BM_##FUNC##_##DIM1##x##DIM2, 128, 5000);
|
|
|
|
|
|
|
|
BM_FuncWithKernelDimsGPU(convolution, 7, 1);
|
|
|
|
BM_FuncWithKernelDimsGPU(convolution, 1, 7);
|
|
|
|
BM_FuncWithKernelDimsGPU(convolution, 7, 4);
|
|
|
|
BM_FuncWithKernelDimsGPU(convolution, 4, 7);
|
|
|
|
BM_FuncWithKernelDimsGPU(convolution, 7, 64);
|
|
|
|
BM_FuncWithKernelDimsGPU(convolution, 64, 7);
|