Scratchpads: Staging in and out data

group aml_scratch

Stage-in, Stage-out High Level Abstraction.

Scratchpad in an abstraction fro moving data back and forth from a data representation in an area to another data representation in another areas. This is especially usefull from moving to user data representation to an architecure optimized representation for heavy computational work, then returning the to user representation. Data movement is performed with two dma engines from one area and tiling to another area and tiling.

build-doxygen/xml/scratch.png

See

aml_dma

Defines

AML_SCRATCH_REQUEST_TYPE_INVALID

Scratchpad request types. Invalid request type. Used for marking inactive requests in the vector.

AML_SCRATCH_REQUEST_TYPE_PUSH

Scratchpad request types. Push from the scratchpad to regular memory.

AML_SCRATCH_REQUEST_TYPE_PULL

Scratchpad request types. Pull from regular memory to the scratchpad.

AML_SCRATCH_REQUEST_TYPE_NOOP

Scratchpad request types. No-op/empty request

Functions

int aml_scratch_pull(struct aml_scratch *scratch, ...)

Requests a synchronous pull from regular memory to the scratchpad.

See

aml_scratch_baseptr()

Return

0 if successful; an error code otherwise.

Parameters
  • scratch: an initialized scratchpad structure.

  • scratchptr: an argument of type void*; the scratchpad base pointer.

  • scratchid: an argument of type int*; gets filled with the scratch tile identifier where the data will be pulled into.

  • srcptr: an argument of type void*; the start address of the complete source user data structure.

  • srcid: an argument of type int; the source tile identifier.

int aml_scratch_async_pull(struct aml_scratch *scratch, struct aml_scratch_request **req, ...)

Requests a pull from regular memory to the scratchpad. This is an asynchronous version of aml_scratch_pull().

Return

0 if successful; an error code otherwise.

See

aml_scratch_pull()

Parameters
  • scratch: an initialized scratchpad structure.

  • req: an address where the pointer to the newly assigned scratch request will be stored.

  • variadic: arguments: see aml_scratch_pull().

int aml_scratch_push(struct aml_scratch *scratch, ...)

Requests a synchronous push from the scratchpad to regular memory.

Return

0 if successful; an error code otherwise.

See

aml_scratch_baseptr()

Parameters
  • scratch: an initialized scratchpad structure.

  • dstptr: an argument of type void*; the start address of the complete destination user data structure.

  • dstid: an argument of type int*; gets filled with the destination tile identifier where the data will be pushed into (and where it was pulled from in the first place).

  • scratchptr: an argument of type void*; the scratchpad base pointer.

  • scratchid: an argument of type int; the scratchpad tile identifier.

int aml_scratch_async_push(struct aml_scratch *scratch, struct aml_scratch_request **req, ...)

Requests a push from the scratchpad to regular memory. This is an asynchronous version of aml_scratch_push().

Return

0 if successful; an error code otherwise.

See

aml_scratch_push()

Parameters
  • scratch: an initialized scratchpad structure.

  • req: an address where the pointer to the newly assigned scratch request will be stored. Variadic arguments: see aml_scratch_push().

int aml_scratch_wait(struct aml_scratch *scratch, struct aml_scratch_request *req)

Waits for an asynchronous scratch request to complete.

Return

0 if successful; an error code otherwise.

Parameters
  • scratch: an initialized scratchpad structure.

  • req: a scratch request obtained using aml_scratch_async_*() calls.

int aml_scratch_cancel(struct aml_scratch *scratch, struct aml_scratch_request *req)

Tears down an asynchronous scratch request before it completes.

Return

0 if successful; an error code otherwise.

Parameters
  • scratch: an initialized scratchpad structure.

  • req: a scratch request obtained using aml_scratch_async_*() calls.

void *aml_scratch_baseptr(const struct aml_scratch *scratch)

Provides the location of the scratchpad.

Return

a base pointer to the scratchpad memory buffer.

Parameters
  • scratch: an initialized scratchpad structure.

int aml_scratch_release(struct aml_scratch *scratch, int scratchid)

Release a scratch tile for immediate reuse.

Return

0 if successful; an error code otherwise.

Parameters
  • scratch: an initialized scratchpad structure.

  • scratchid: a scratchpad tile identifier.

struct aml_scratch_ops
#include <aml.h>

aml_scratch_ops contain a scratch implementation specific operations. These operations implementation may vary depending on the source and destination of data, and thus scratch implementations use different operations. Aware users may create or modify implementation by assembling appropriate operations in such a structure.

See

struct aml_scratch

struct aml_scratch
#include <aml.h>

An aml_scratch is abstraction aimed toward temporary use of a data structures in a different area than the one where data currently resides. Scratches in AML take care of asynchornously allocating and moving the data back and forth between areas.