Module: Cumo::CUDA::Runtime

Defined in:
ext/cumo/cuda/runtime.c

Class Method Summary collapse

Class Method Details

.cudaDeviceGetAttributes(attrib, device) ⇒ Integer

Returns information about the device.

Parameters:

  • attrib (Integer)

    Device attribute to query

  • device (Integer)

    Device number to query

Returns:

  • (Integer)

    Returned device attribute value

Raises:

See Also:



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'ext/cumo/cuda/runtime.c', line 79

static VALUE
rb_cudaDeviceGetAttributes(VALUE self, VALUE attrib, VALUE device)
{
    int _attrib = NUM2INT(attrib);
    int _device = NUM2INT(device);
    int _ret;
    cudaError_t status;

    status = cudaDeviceGetAttribute(&_ret, _attrib, _device);

    check_status(status);
    return INT2NUM(_ret);
}

.cudaDeviceSynchronizeObject

Wait for compute device to finish.



131
132
133
134
135
136
137
138
# File 'ext/cumo/cuda/runtime.c', line 131

static VALUE
rb_cudaDeviceSynchronize(VALUE self)
{
    cudaError_t status;
    status = cudaDeviceSynchronize();
    check_status(status);
    return Qnil;
}

.cudaDriverGetVersionInteger

Returns the CUDA driver version.



23
24
25
26
27
28
29
30
31
32
33
# File 'ext/cumo/cuda/runtime.c', line 23

static VALUE
rb_cudaDriverGetVersion(VALUE self)
{
    int _version;
    cudaError_t status;

    status = cudaDriverGetVersion(&_version);

    check_status(status);
    return INT2NUM(_version);
}

.cudaGetDeviceInteger

Returns which device is currently being used.

Returns:

  • (Integer)

    Returns the device on which the active host thread executes the device code.

Raises:

See Also:



64
65
66
67
68
# File 'ext/cumo/cuda/runtime.c', line 64

static VALUE
rb_cudaGetDevice(VALUE self)
{
    return INT2NUM(cumo_cuda_runtime_get_device());
}

.cudaGetDeviceCountInteger

Returns the number of compute-capable devices.

Returns:

  • (Integer)

    Returns the number of devices with compute capability greater or equal to 2.0

Raises:

See Also:



100
101
102
103
104
# File 'ext/cumo/cuda/runtime.c', line 100

static VALUE
rb_cudaGetDeviceCount(VALUE self)
{
    return INT2NUM(cumo_cuda_runtime_get_device_count());
}

.cudaRuntimeGetVersionInteger

Returns the CUDA Runtime version.



41
42
43
44
45
46
47
48
49
50
51
# File 'ext/cumo/cuda/runtime.c', line 41

static VALUE
rb_cudaRuntimeGetVersion(VALUE self)
{
    int _version;
    cudaError_t status;

    status = cudaRuntimeGetVersion(&_version);

    check_status(status);
    return INT2NUM(_version);
}

.cudaSetDevice(device) ⇒ Object

Set device to be used for GPU executions.

Parameters:

  • device (Integer)

    Device on which the active host thread should execute the device code.

Raises:

See Also:



113
114
115
116
117
118
119
120
121
122
123
# File 'ext/cumo/cuda/runtime.c', line 113

static VALUE
rb_cudaSetDevice(VALUE self, VALUE device)
{
    int _device = NUM2INT(device);
    cudaError_t status;

    status = cudaSetDevice(_device);

    check_status(status);
    return Qnil;
}