Skip to content

Allocator API Update #103

@ryanmrichard

Description

@ryanmrichard

At the moment the Allocator class combines allocation and initialization into one step. It should probably be two steps allocate and then construct, per the following quoted discussion. This issue is for implementing said API.

Original text:

I didn't realize allocate had this sort of API. This is going to mess up the tag system (tags aren't going to map uniquely to functions). I was envisioning that internally each direct Allocator contained a tag and a function and that allocate took a Shape and returns an "allocated but uninitialized" Buffer. In the direct case, Allocator would construct a TABuffer wrapping a tensor with lazy tiles; in the normal Allocator class you'd make a tensor with normal tiles. Both of them would just be constructed, not intitialized. With a normal C++ allocator the initialization is done with the construct method.

So what I would do is have one allocate method which takes a Shape. In the allocate method I would call this TA ctor. I'd then add a function construct with the API:

Buffer Allocator::construct(Buffer b, Fxn f);

where for the normal allocator you do something like:

// Convert input buffer to TA array
// Use TA array to call make_array
return TA::make_array(b.world(), b.trange(), f);

and for the lazy tile you either throw or ignore the provided function (this assumes that for lazy tiles there's no additional initialization beyond calling the TA ctor I linked to above).

Originally posted by @ryanmrichard in #102 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions