#!/bin/env ruby

$: << File.join(File.dirname(__FILE__), '..', 'lib')
require 'coo-coo/cuda'

unless CooCoo::CUDA.available?
  puts("Cuda not available")
  exit(-1)
end

puts("Device\t#{CooCoo::CUDA::Runtime.get_device} / #{CooCoo::CUDA::Runtime.device_count}")
props = CooCoo::CUDA::Runtime::DeviceProperties.new
err = CooCoo::CUDA::Runtime.cudaGetDeviceProperties(props, 0)
raise CUDAError(err) if err != 0

props.members.each do |m|
  value = props[m]
  if m != :name && value.kind_of?(FFI::Struct::InlineArray)
    value.each_with_index do |v, i|
      puts("#{m}[#{i}]\t#{v}")
    end
  else
    puts("#{m}\t#{value}")
  end
end
