Ceed

A Ceed is a library context representing control of a logical hardware resource.

Base library resources

typedef struct Ceed_private *Ceed

Library context created by CeedInit()

typedef struct CeedRequest_private *CeedRequest

Non-blocking Ceed interfaces return a CeedRequest.

To perform an operation immediately, pass CEED_REQUEST_IMMEDIATE instead.

CeedRequest *const CEED_REQUEST_IMMEDIATE = &ceed_request_immediate

Request immediate completion.

This predefined constant is passed as the CeedRequest argument to interfaces when the caller wishes for the operation to be performed immediately. The code

CeedOperatorApply(op, ..., CEED_REQUEST_IMMEDIATE);

is semantically equivalent to

CeedRequest request;
CeedOperatorApply(op, ..., &request);
CeedRequestWait(&request);

See

CEED_REQUEST_ORDERED

CeedRequest *const CEED_REQUEST_ORDERED = &ceed_request_ordered

Request ordered completion.

This predefined constant is passed as the CeedRequest argument to interfaces when the caller wishes for the operation to be completed in the order that it is submitted to the device. It is typically used in a construct such as

CeedRequest request;
CeedOperatorApply(op1, ..., CEED_REQUEST_ORDERED);
CeedOperatorApply(op2, ..., &request);
// other optional work
CeedWait(&request);

which allows the sequence to complete asynchronously but does not start op2 until op1 has completed.

See

CEED_REQUEST_IMMEDIATE

int CeedRequestWait(CeedRequest *req)

Wait for a CeedRequest to complete.

Calling CeedRequestWait on a NULL request is a no-op.

User Functions

Return

An error code: 0 - success, otherwise - failure

Parameters
  • req: Address of CeedRequest to wait for; zeroed on completion.

int CeedInit(const char *resource, Ceed *ceed)

Initialize a Ceed: core components context to use the specified resource.

User Functions

See

CeedRegister() CeedDestroy()

Return

An error code: 0 - success, otherwise - failure

Parameters
  • resource: Resource to use, e.g., “/cpu/self”

  • ceed: The library context

int CeedGetResource(Ceed ceed, const char **resource)

Get the full resource name for a Ceed context.

User Functions

Return

An error code: 0 - success, otherwise - failure

Parameters
  • ceed: Ceed context to get resource name of

  • [out] resource: Variable to store resource name

int CeedGetPreferredMemType(Ceed ceed, CeedMemType *type)

Return Ceed context preferred memory type.

User Functions

Return

An error code: 0 - success, otherwise - failure

Parameters
  • ceed: Ceed context to get preferred memory type of

  • [out] type: Address to save preferred memory type to

int CeedIsDeterministic(Ceed ceed, bool *isDeterministic)

Get deterministic status of Ceed.

User Functions

Return

An error code: 0 - success, otherwise - failure

Parameters
  • [in] ceed: Ceed

  • [out] isDeterministic: Variable to store deterministic status

int CeedView(Ceed ceed, FILE *stream)

View a Ceed.

User Functions

Return

An error code: 0 - success, otherwise - failure

Parameters
  • [in] ceed: Ceed to view

  • [in] stream: Filestream to write to

int CeedDestroy(Ceed *ceed)

Destroy a Ceed context.

User Functions

Return

An error code: 0 - success, otherwise - failure

Parameters
  • ceed: Address of Ceed context to destroy

int CeedErrorImpl(Ceed ceed, const char *filename, int lineno, const char *func, int ecode, const char *format, ...)

Error handling implementation; use CeedError instead.

Library Developer Functions

int CeedErrorReturn(Ceed ceed, const char *filename, int lineno, const char *func, int ecode, const char *format, va_list args)

Error handler that returns without printing anything.

Ceed error handlers.

Pass this to CeedSetErrorHandler() to obtain this error handling behavior.

Library Developer Functions

int CeedErrorStore(Ceed ceed, const char *filename, int lineno, const char *func, int ecode, const char *format, va_list args)

Error handler that stores the error message for future use and returns the error.

Pass this to CeedSetErrorHandler() to obtain this error handling behavior.

Library Developer Functions

int CeedErrorAbort(Ceed ceed, const char *filename, int lineno, const char *func, int ecode, const char *format, va_list args)

Error handler that prints to stderr and aborts.

Pass this to CeedSetErrorHandler() to obtain this error handling behavior.

Library Developer Functions

int CeedErrorExit(Ceed ceed, const char *filename, int lineno, const char *func, int ecode, const char *format, va_list args)

Error handler that prints to stderr and exits.

Pass this to CeedSetErrorHandler() to obtain this error handling behavior.

In contrast to CeedErrorAbort(), this exits without a signal, so atexit() handlers (e.g., as used by gcov) are run.

Library Developer Functions

int CeedSetErrorHandler(Ceed ceed, int (*eh)(Ceed, const char*, int, const char*, int, const char*, va_list))

Set error handler.

A default error handler is set in CeedInit(). Use this function to change the error handler to CeedErrorReturn(), CeedErrorAbort(), or a user-defined error handler.

Library Developer Functions

int CeedGetErrorMessage(Ceed ceed, const char **errmsg)

Get error message.

The error message is only stored when using the error handler CeedErrorStore()

Library Developer Functions

Parameters
  • [in] ceed: Ceed contex to retrieve error message

  • [out] errmsg: Char pointer to hold error message

int CeedResetErrorMessage(Ceed ceed, const char **errmsg)

Restore error message.

The error message is only stored when using the error handler CeedErrorStore()

Library Developer Functions

Parameters
  • [in] ceed: Ceed contex to restore error message

  • [out] errmsg: Char pointer that holds error message

Macros

CeedError(ceed, ecode, ...)

Raise an error on ceed object.

See

CeedSetErrorHandler()

Parameters
  • ceed: Ceed library context or NULL

  • ecode: Error code (int)

  • ...: printf-style format string followed by arguments as needed

CeedPragmaSIMD

This macro provides the appropriate SIMD Pragma for the compilation environment.

Code generation backends may redefine this macro, as needed.

Typedefs and Enumerations

enum CeedMemType

Specify memory type.

Many Ceed interfaces take or return pointers to memory. This enum is used to specify where the memory being provided or requested must reside.

Values:

enumerator CEED_MEM_HOST

Memory resides on the host.

enumerator CEED_MEM_DEVICE

Memory resides on a device (corresponding to Ceed: core components resource)