https://github.com/Microsoft/CNTK
Raw File
Tip revision: 27f2858da789549062186fde75e11296b5bf4c40 authored by Gaizka Navarro on 25 April 2016, 13:47:10 UTC
This commit fixes the WriteMiniBatchWithFormatting method to correctly write the matrix. Prior, it was not writing all the columns.
Tip revision: 27f2858
cudadevice.h
// cudadevice.h - holds the buffers, events, and streams used on a per device basis
//
// F. Seide, V-hansu

#pragma once

#include <cuda_runtime_api.h>
#include <assert.h>
#include <math.h>
#include <vector>
#include <unordered_set>

namespace msra { namespace cuda {

const int deviceMax = 8;

// an object that lives in a device --this class just implements setdevice() and associated storage, and is shared across matrix and vectorbaseimpl
class objectondevice
{
protected:
    size_t deviceid; // CUDA card in which this matrix lives ("virtual" index amongst cards allocated to this process); default: 0
protected:
    objectondevice(size_t d)
        : deviceid(d)
    {
    }

public:
    size_t getdevice() const
    {
        return deviceid;
    }
};

// auto-class to set device (through context) inside a function
// usage at each function that calls CUDA:
//  ondevice no (deviceid);
class ondevice
{
public:
    ondevice(size_t deviceid)
    {
        cudaSetDevice((int) deviceid) || "cudaSetDevice failed!";
    }
    ~ondevice()
    {
    }
};
} }
back to top