Ejemplo n.º 1
0
func DeviceReset() {
	err := Error(C.cudaDeviceReset())
	if err != Success {
		panic(err)
	}
	return
}
Ejemplo n.º 2
0
func NewDevice(busID string) (*Device, error) {
	var (
		dev  C.int
		prop C.struct_cudaDeviceProp
	)

	id := C.CString(busID)
	if err := cudaErr(C.cudaDeviceGetByPCIBusId(&dev, id)); err != nil {
		return nil, err
	}
	C.free(unsafe.Pointer(id))

	if err := cudaErr(C.cudaGetDeviceProperties(&prop, dev)); err != nil {
		return nil, err
	}
	arch := fmt.Sprintf("%d.%d", prop.major, prop.minor)
	cores, ok := archToCoresPerSM[arch]
	if !ok {
		return nil, fmt.Errorf("unsupported CUDA arch: %s", arch)
	}

	// Destroy the active CUDA context
	cudaErr(C.cudaDeviceReset())

	return &Device{
		handle: dev,
		Family: archToFamily[arch[:1]],
		Arch:   arch,
		Cores:  cores * uint(prop.multiProcessorCount),
		Memory: MemoryInfo{
			ECC:       bool(prop.ECCEnabled != 0),
			Global:    uint(prop.totalGlobalMem / (1024 * 1024)),
			Shared:    uint(prop.sharedMemPerMultiprocessor / 1024),
			Constant:  uint(prop.totalConstMem / 1024),
			L2Cache:   uint(prop.l2CacheSize / 1024),
			Bandwidth: 2 * uint((prop.memoryClockRate/1000)*(prop.memoryBusWidth/8)) / 1000,
		},
	}, nil
}
Ejemplo n.º 3
0
func deviceReset() error {
	return errorString(C.cudaDeviceReset())
}
Ejemplo n.º 4
0
// Reset the current GPU device.
func DeviceReset() {
	err := cu.Result(C.cudaDeviceReset())
	if err != cu.SUCCESS {
		panic(err)
	}
}