Home | History | Annotate | Download | only in tensors
      1 #define EIGEN_USE_THREADS
      2 
      3 #include <string>
      4 
      5 #include "tensor_benchmarks.h"
      6 
      7 #define CREATE_THREAD_POOL(threads)             \
      8 Eigen::ThreadPool pool(threads);                \
      9 Eigen::ThreadPoolDevice device(&pool, threads);
     10 
     11 
     12 // Contractions for number of threads ranging from 1 to 32
     13 // Dimensions are Rows, Cols, Depth
     14 #define BM_ContractionCPU(D1, D2, D3)                                         \
     15   static void BM_##Contraction##_##D1##x##D2##x##D3(int iters, int Threads) { \
     16     StopBenchmarkTiming();                                                    \
     17     CREATE_THREAD_POOL(Threads);                                              \
     18     BenchmarkSuite<Eigen::ThreadPoolDevice, float> suite(device, D1, D2, D3); \
     19     suite.contraction(iters);                                                 \
     20   }                                                                           \
     21   BENCHMARK_RANGE(BM_##Contraction##_##D1##x##D2##x##D3, 1, 32);
     22 
     23 
     24 // Vector Matrix and Matrix Vector products
     25 BM_ContractionCPU(1, 2000, 500);
     26 BM_ContractionCPU(2000, 1, 500);
     27 
     28 // Various skinny matrices
     29 BM_ContractionCPU(250, 3, 512);
     30 BM_ContractionCPU(1500, 3, 512);
     31 
     32 BM_ContractionCPU(512, 800, 4);
     33 BM_ContractionCPU(512, 80, 800);
     34 BM_ContractionCPU(512, 80, 13522);
     35 BM_ContractionCPU(1, 80, 13522);
     36 
     37 BM_ContractionCPU(3200, 512, 4);
     38 BM_ContractionCPU(3200, 512, 80);
     39 BM_ContractionCPU(3200, 80, 512);
     40