Module: Cumo::CUDA::MemoryPool

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

Class Method Summary collapse

Class Method Details

.disableBoolean

Disable memory pool.

Returns:

  • (Boolean)

    Returns previous state (true if enabled)



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

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

.enableBoolean

Enable memory pool.

Returns:

  • (Boolean)

    Returns previous state (true if enabled)



62
63
64
65
66
67
68
# File 'ext/cumo/cuda/memory_pool.cpp', line 62

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

.enabled?Boolean

Returns whether memory pool is enabled or not.

Returns:

  • (Boolean)

    Returns the state (true if enabled)



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

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

.free_all_blocks(*args) ⇒ Object

Free all non-split chunks in all arenas.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'ext/cumo/cuda/memory_pool.cpp', line 97

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_bytesInteger

Get the total number of bytes acquired but not used in the pool.

Returns:

  • (Integer)

    The total number of bytes acquired but not used in the pool.



141
142
143
144
145
# File 'ext/cumo/cuda/memory_pool.cpp', line 141

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

.n_free_blocksInteger

Count the total number of free blocks.

Returns:

  • (Integer)

    The total number of free blocks.



119
120
121
122
123
# File 'ext/cumo/cuda/memory_pool.cpp', line 119

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

.total_bytesInteger

Get the total number of bytes acquired in the pool.

Returns:

  • (Integer)

    The total number of bytes acquired in the pool.



152
153
154
155
156
# File 'ext/cumo/cuda/memory_pool.cpp', line 152

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

.used_bytesInteger

Get the total number of bytes used.

Returns:

  • (Integer)

    The total number of bytes used.



130
131
132
133
134
# File 'ext/cumo/cuda/memory_pool.cpp', line 130

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