#include "libscl.h"
#include "cuda.h"
#include "cuda_runtime.h"
#include "cublas.h"

using namespace std;

int main(int argc, char** argp, char** envp)
{
  cudaError_t err;

  int deviceCount;
  cudaGetDeviceCount(&deviceCount);

  int device;
  cudaDeviceProp deviceProp;

  cout << '\n';
  cout << "Device count = " << deviceCount << '\n';
  cout << '\n';

  for (device = 0; device < deviceCount; ++device) {
    cout << '\n';
    cout << "Properties for device " << device << '\n';
    err = cudaGetDeviceProperties(&deviceProp, device);
    if (err == cudaSuccess) {
      cout << '\n';
      cout << "Device characteristics" << '\n';
      cout << "\tname = " << deviceProp.name << '\n';
      cout << "\ttotalGlobalMem = " << deviceProp.totalGlobalMem << '\n';
      cout << "\tsharedMemPerBlock = " << deviceProp.sharedMemPerBlock << '\n';
      cout << "\tregsPerBlock = " << deviceProp.regsPerBlock << '\n';
      cout << "\twarpSize = " << deviceProp.warpSize << '\n';
      cout << "\tmemPitch = " << deviceProp.memPitch << '\n';
      cout << "\tmaxThreadsPerBlock = " << deviceProp.maxThreadsPerBlock<<'\n';
      cout << "\tmaxThreadsDim = " << deviceProp.maxThreadsDim[0] << ' '
           << deviceProp.maxThreadsDim[1] << ' '
           << deviceProp.maxThreadsDim[2] << '\n';
      cout << "\tmaxGridSize = " << deviceProp.maxGridSize[0] << ' '
           << deviceProp.maxGridSize[1] << ' '
           << deviceProp.maxGridSize[2] << '\n';
      cout << "\ttotalConstMem = " << deviceProp.totalConstMem << '\n';
      cout << "\tdeviceProp.major = " << deviceProp.major << '\n';
      cout << "\tdeviceProp.minor = " << deviceProp.minor << '\n';
      cout << "\tclockRate = " << deviceProp.clockRate << '\n';
      cout << "\ttextureAlignment = " << deviceProp.textureAlignment << '\n';
      cout << "\tdeviceOverlap = " << deviceProp.deviceOverlap << '\n';
      cout << "\tmultiProcessorCount = "
           << deviceProp.multiProcessorCount << '\n';
      cout << "\tkernelExecTimeoutEnabled = "
           << deviceProp.kernelExecTimeoutEnabled << '\n';
      cout << "\tintegrated = " << deviceProp.integrated << '\n';
      cout << "\tcanMapHostMemory = " << deviceProp.canMapHostMemory << '\n';
      cout << "\tcomputeMode = " << deviceProp.computeMode << '\n';
      cout << '\n';
    }
  }
  return 0;
}

