Jakowlew

common

Dec 5th, 2020
808
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2. #include <iostream>
  3. #include <cublas_v2.h>
  4.  
  5. struct launch_params
  6. {
  7.     cublasHandle_t cublasHandle = nullptr;
  8.     cudaStream_t stream = 0;
  9.     int threadsPerBlock = 512;
  10.     bool pinnedMemory = false;
  11. };
  12.  
  13. template <typename T>
  14. inline void print_matrix1(const T *A, int m, int n)
  15. {
  16.     for(int i = 0; i < m; ++i)
  17.     {
  18.         for(int j = 0; j < n; ++j)
  19.             std::cout << A[j * m + i] << " ";
  20.         std::cout << '\n';
  21.     }
  22.     std::cout << '\n';
  23. }
  24.  
  25. template <typename T>
  26. struct Id {};
  27.  
  28. template <typename T>
  29. struct Zero {};
  30.  
  31. template <typename T>
  32. struct mId {};
  33.  
  34. template <typename T>
  35. struct AlmostZero {};
  36.  
  37. // Shortcuts
  38.  
  39. template <typename T>
  40. constexpr T Id_v = Id<T>::value;
  41.  
  42. template <typename T>
  43. constexpr T Zero_v = Zero<T>::value;
  44.  
  45. template <typename T>
  46. constexpr T mId_v = mId<T>::value;
  47.  
  48. template <typename T>
  49. constexpr T AlmostZero_v = AlmostZero<T>::value;
  50.  
RAW Paste Data