Sha256: 3cac0a3ca2b8962d0d37ab40d4ec01b95a86d5ca4e19974aba1856943e3eeec9

Contents?: true

Size: 1009 Bytes

Versions: 19

Compression:

Stored size: 1009 Bytes

Contents

static VALUE
<%=c_func(0)%>(VALUE self)
{
    cumo_narray_t *na;
    void *ptr;

    CumoGetNArray(self,na);

    switch(CUMO_NA_TYPE(na)) {
    case CUMO_NARRAY_DATA_T:
        ptr = CUMO_NA_DATA_PTR(na);
        if (na->size > 0 && ptr == NULL) {
            <% if is_object %>
            ptr = xmalloc(sizeof(dtype) * na->size);
            {   size_t i;
                VALUE *a = (VALUE*)ptr;
                for (i=na->size; i--;) {
                    *a++ = Qnil;
                }
            }
            <% else %>
            ptr = cumo_cuda_runtime_malloc(sizeof(dtype) * na->size);
            <% end %>
            CUMO_NA_DATA_PTR(na) = ptr;
        }
        break;
    case CUMO_NARRAY_VIEW_T:
        rb_funcall(CUMO_NA_VIEW_DATA(na), rb_intern("allocate"), 0);
        break;
    case CUMO_NARRAY_FILEMAP_T:
        //ptr = ((cumo_narray_filemap_t*)na)->ptr;
        // to be implemented
    default:
        rb_bug("invalid narray type : %d",CUMO_NA_TYPE(na));
    }
    return self;
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
cumo-0.4.3 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.4.2 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.4.1 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.4.0 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.3.5 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.3.4 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.3.3 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.3.2 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.3.1 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.3.0 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.3.0.pre1 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.2.5 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.2.4 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.2.3 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.2.2 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.2.1 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.2.0 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.1.2 ext/cumo/narray/gen/tmpl/allocate.c
cumo-0.1.1 ext/cumo/narray/gen/tmpl/allocate.c