|
Packit |
534379 |
===========================
|
|
Packit |
534379 |
OPAE C++ Core API Reference
|
|
Packit |
534379 |
===========================
|
|
Packit |
534379 |
|
|
Packit |
534379 |
The reference documentation for the OPAE C++ Core API is grouped into the following
|
|
Packit |
534379 |
sections:
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. contents::
|
|
Packit |
534379 |
:local:
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Overview
|
|
Packit |
534379 |
========
|
|
Packit |
534379 |
|
|
Packit |
534379 |
The OPAE C++ API enables C++ developers with the means to use FPGA resources
|
|
Packit |
534379 |
by integrating the OPAE software stack into C++ applications.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Goals
|
|
Packit |
534379 |
=====
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Simplicity
|
|
Packit |
534379 |
----------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Keep the API as small and lightweight as possible. Although features such as
|
|
Packit |
534379 |
system validation and orchestration are beyond the scope of this API, using
|
|
Packit |
534379 |
this API for their development should be relatively easy.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Extensibility and Interoperability
|
|
Packit |
534379 |
----------------------------------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
While keeping to the goal of simplicity, the OPAE C++ API is designed to allow
|
|
Packit |
534379 |
for better reuse by either extending the API or by integrating with other
|
|
Packit |
534379 |
languages.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Modern C++ Coding Practices
|
|
Packit |
534379 |
---------------------------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
The OPAE C++ API uses the C++ 11 standard library and makes use of its features
|
|
Packit |
534379 |
whenever practical. The OPAE C++ API is also designed to require the minimum
|
|
Packit |
534379 |
number of third-party libraries/dependencies.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Error Handling
|
|
Packit |
534379 |
--------------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
The OPAE C++ API is designed to throw exceptions when appropriate. The
|
|
Packit |
534379 |
structure of OPAE C++ exceptions is similar to the error codes in the
|
|
Packit |
534379 |
OPAE C API. This gives users of the API more freedom on error handling
|
|
Packit |
534379 |
while providing better debug information in cases of failure.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Coding Style
|
|
Packit |
534379 |
------------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
For formatting of the OPAE C++ API complies with most of the recommendations
|
|
Packit |
534379 |
of the Google C++ style. For example, the OPAE C++ API uses:
|
|
Packit |
534379 |
|
|
Packit |
534379 |
* opening braces on the same line as their scope definition
|
|
Packit |
534379 |
* spaces instead of tabs for indentation
|
|
Packit |
534379 |
* indentation of two spaces
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Fundamental Types
|
|
Packit |
534379 |
=================
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Basic types for the OPAE C++ API are found in the `opae::fpga::types`
|
|
Packit |
534379 |
namespace. They serve as an adapter layer between the OPAE C API and
|
|
Packit |
534379 |
the OPAE C++ layer. Aside from providing a C++ binding to the C
|
|
Packit |
534379 |
fundamental types, these types also:
|
|
Packit |
534379 |
|
|
Packit |
534379 |
* manage the lifetime and scope of the corresponding C struct.
|
|
Packit |
534379 |
* For example a C++ destructor will take care of calling the
|
|
Packit |
534379 |
appropriate C function to release the data structure being
|
|
Packit |
534379 |
wrapped.
|
|
Packit |
534379 |
* provide a friendly syntax for using the OPAE C type.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Most classes in this namespace have a `c_type()` method that returns
|
|
Packit |
534379 |
the C data structure being wrapped, making it easy to use the OPAE C++
|
|
Packit |
534379 |
type with the OPAE C API. Alternatively, most classes in this namespace
|
|
Packit |
534379 |
have implicit conversion operators that enable interoperability with
|
|
Packit |
534379 |
the OPAE C API.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Properties
|
|
Packit |
534379 |
----------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
C++ class `properties` wraps `fpga_properties` and uses `pvalue`
|
|
Packit |
534379 |
and `guid_t` to get and set properties stored in an instance of
|
|
Packit |
534379 |
an `fpga_properties`. `pvalue` and `guid_t` are designed to call
|
|
Packit |
534379 |
an accessor method in the OPAE C API to either read property
|
|
Packit |
534379 |
values or write them. Most accessor methods in the OPAE C API
|
|
Packit |
534379 |
share a similar signature, so `pvalue` generalizes them into
|
|
Packit |
534379 |
common operations that translate into calling the corresponding
|
|
Packit |
534379 |
C API function. `guid_t` follows similar patterns when reading
|
|
Packit |
534379 |
or assigning values.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
pvalue.h
|
|
Packit |
534379 |
--------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/pvalue.h
|
|
Packit |
534379 |
|
|
Packit |
534379 |
properties.h
|
|
Packit |
534379 |
------------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/properties.h
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Resource Classes
|
|
Packit |
534379 |
----------------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
The `token`, `handle`, and `shared_buffer` classes are used to
|
|
Packit |
534379 |
enumerate and access FPGA resources. `properties` are used to
|
|
Packit |
534379 |
narrow the search space for `token`'s. Before enumerating the
|
|
Packit |
534379 |
accelerator resources in the system, applications can produce
|
|
Packit |
534379 |
one or more `properties` objects whose values are set to the
|
|
Packit |
534379 |
desired characteristics for the resource. For example, an
|
|
Packit |
534379 |
application may search for an accelerator resource based on
|
|
Packit |
534379 |
its guid.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Once one or more `token`'s have been enumerated, the application
|
|
Packit |
534379 |
must choose which `token`'s to request. The `token` is then
|
|
Packit |
534379 |
converted to a `handle` by requesting that a `handle` object
|
|
Packit |
534379 |
be allocated and opened for it.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Once a `handle` has been successfully opened, the application
|
|
Packit |
534379 |
can read and write the associated configuration and status
|
|
Packit |
534379 |
space. Additionally, the application may use the `handle` to
|
|
Packit |
534379 |
allocate `shared_buffer`'s or to register `event`'s. The
|
|
Packit |
534379 |
`shared_buffer` and `event` objects retain a reference to
|
|
Packit |
534379 |
their owning `handle` so that the `handle` does not lose
|
|
Packit |
534379 |
scope before freeing the `shared_buffer` and `event` objects.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
token.h
|
|
Packit |
534379 |
--------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/token.h
|
|
Packit |
534379 |
|
|
Packit |
534379 |
handle.h
|
|
Packit |
534379 |
--------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/handle.h
|
|
Packit |
534379 |
|
|
Packit |
534379 |
shared_buffer.h
|
|
Packit |
534379 |
--------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/shared_buffer.h
|
|
Packit |
534379 |
|
|
Packit |
534379 |
errors.h
|
|
Packit |
534379 |
-------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/errors.h
|
|
Packit |
534379 |
|
|
Packit |
534379 |
events.h
|
|
Packit |
534379 |
-------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/events.h
|
|
Packit |
534379 |
|
|
Packit |
534379 |
sysobject.h
|
|
Packit |
534379 |
-------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/sysobject.h
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Exceptions
|
|
Packit |
534379 |
----------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
When the OPAE C++ API encounters an error from the OPAE C
|
|
Packit |
534379 |
API, it captures the current source code location and
|
|
Packit |
534379 |
the error code into an object of type `except`, then
|
|
Packit |
534379 |
throws the `except`. Applications should implement the
|
|
Packit |
534379 |
appropriate catch blocks required to respond to runtime
|
|
Packit |
534379 |
exceptions.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
except.h
|
|
Packit |
534379 |
--------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/except.h
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Misc
|
|
Packit |
534379 |
----
|
|
Packit |
534379 |
|
|
Packit |
534379 |
The `version` class wraps the OPAE C version API.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
version.h
|
|
Packit |
534379 |
--------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
.. doxygenfile:: include/opae/cxx/core/version.h
|
|
Packit |
534379 |
|