Module: Cumo::CUDA::MemoryPool

Defined in:
ext/cumo/cuda/memory_pool.cpp

Class Method Summary collapse

Class Method Details

.disableObject



89
90
91
92
93
94
95
# File 'ext/cumo/cuda/memory_pool.cpp', line 89

static VALUE
rb_memory_pool_disable(VALUE self)
{
    VALUE ret = (memory_pool_enabled ? Qtrue : Qfalse);
    memory_pool_enabled = false;
    return ret;
}

.enableObject



76
77
78
79
80
81
82
# File 'ext/cumo/cuda/memory_pool.cpp', line 76

static VALUE
rb_memory_pool_enable(VALUE self)
{
    VALUE ret = (memory_pool_enabled ? Qtrue : Qfalse);
    memory_pool_enabled = true;
    return ret;
}

.enabled?Object



102
103
104
105
106
# File 'ext/cumo/cuda/memory_pool.cpp', line 102

static VALUE
rb_memory_pool_enabled_p(VALUE self)
{
    return (memory_pool_enabled ? Qtrue : Qfalse);
}

.free_all_blocks(*args) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'ext/cumo/cuda/memory_pool.cpp', line 111

static VALUE
rb_memory_pool_free_all_blocks(int argc, VALUE* argv, VALUE self)
{
    try {
        if (argc < 1) {
            pool.FreeAllBlocks();
        } else {
            // TODO(sonots): FIX if we create a Stream object
            cudaStream_t stream_ptr = (cudaStream_t)NUM2SIZET(argv[0]);
            pool.FreeAllBlocks(stream_ptr);
        }
    } catch (const cumo::internal::CUDARuntimeError& e) {
        cumo_cuda_runtime_check_status(e.status());
    }
    return Qnil;
}

.free_bytesObject



155
156
157
158
159
# File 'ext/cumo/cuda/memory_pool.cpp', line 155

static VALUE
rb_memory_pool_free_bytes(VALUE self)
{
    return SIZET2NUM(pool.GetFreeBytes());
}

.n_free_blocksObject



133
134
135
136
137
# File 'ext/cumo/cuda/memory_pool.cpp', line 133

static VALUE
rb_memory_pool_n_free_blocks(VALUE self)
{
    return SIZET2NUM(pool.GetNumFreeBlocks());
}

.total_bytesObject



166
167
168
169
170
# File 'ext/cumo/cuda/memory_pool.cpp', line 166

static VALUE
rb_memory_pool_total_bytes(VALUE self)
{
    return SIZET2NUM(pool.GetTotalBytes());
}

.used_bytesObject



144
145
146
147
148
# File 'ext/cumo/cuda/memory_pool.cpp', line 144

static VALUE
rb_memory_pool_used_bytes(VALUE self)
{
    return SIZET2NUM(pool.GetUsedBytes());
}