Cyborg FPGA 模型提案

蓝图 URL 尚未可用 https://blueprints.launchpad.net/openstack-cyborg/+spec/cyborg-fpga-modelling

本文档提出了用于跟踪可编程资源的数据库建模方案

问题描述

现场可编程门阵列 (FPGA) 是一种集成电路,设计为在制造后由客户或设计者进行配置。它们的优势在于,对于某些应用,由于其并行性和在特定工艺中使用的门数量的优化,它们有时会显著更快。因此,在云中使用 FPGA 进行应用加速变得越来越受欢迎。Cyborg 作为异构加速器的管理框架,跟踪和部署 FPGA 是非常必要的特性。

用例

当用户请求 FPGA 资源时,调度器将使用 placement agent 1 来选择具有请求的 FPGA 资源的合适主机。

当 FPGA 类型的资源分配给虚拟机时,Cyborg 需要在数据库中跟踪分配了哪个确切的设备。另一方面,当资源释放时,Cyborg 需要将其分离并释放确切的资源。

当新设备插入系统(主机)时,Cyborg 需要发现它并将其存储到数据库中

提议的变更

我们需要向 Cyborg 数据库添加 2 个表,一个用于跟踪所有可部署资源,另一个用于与可部署资源关联的任意键值对属性。这些表分别命名为 Deployables 和 Attributes。

Deployables 表包含所有通用属性列以及 parent_id 和 root_id。parent_id 将指向关联的父可部署资源,root_id 将指向关联的根可部署资源。通过这种方式,我们可以形成嵌套树结构来表示不同的层次结构。此外,将有一个名为 accelerator_id 的外键引用 accelerators 表。对于尚未加载任何比特流的 FPGA 的情况,它们仍然会被跟踪为 Deployable,但没有其他 Deployables 引用它们。例如,可以使用 Deployables 形成 FPGA 层次结构的网络,如下所示

                        -------------------
    ------------------->|Deployable - FPGA|<--------------------
    |                   -------------------                    |
    |                           /\                             |
    | root_id                  /  \  parent_id/root_id         |
    |                         /    \                           |
    |         -----------------    -----------------           |
    |         |Deployable - PF|    |Deployable - PF|           |
    |         -----------------    -----------------           |
    |               /\                                         |
    |              /  \  parent_id                     root_id |
    |             /    \                                       |
-----------------      -----------------                       |
|Deployable - VF|      |Deployable - VF| -----------------------
-----------------      -----------------

Attributes 表包含一个 key 列和一个 value 列,用于表示任意的键值对。

例如,bitstream_id 和 function kpi 可以在此表中跟踪。此外,一个外键 deployable_id 引用 Deployables 表,一个 parent_attribute_id 用于形成嵌套结构的属性关系。

Cyborg 需要具有对象类来表示不同类型的可部署资源(例如,FPGA、物理功能、虚拟功能等)。

Cyborg Agent 需要添加功能来从 FPGA 驱动程序发现 FPGA 资源,并通过 conductor 将它们报告到 Cyborg DB。

Conductor 需要添加一些用于不同类型可部署资源的 API。

备选方案

或者,与其使用一个扁平的表来跟踪任意层次结构,我们可以使用 Cyborg 数据库中的两个不同的表,一个用于物理功能,一个用于虚拟功能。physical_functions 应该有一个外键约束来引用 Accelerators 表中的 id。此外,virtual_functions 应该有一个外键约束来引用 physical_functions 中的 id。

此设计的缺点如下。首先,它只能跟踪最多 3 层资源。如果我们需要添加另一层,将需要大量的迁移工作。其次,即使我们只需要向现有资源类型添加一些新属性,我们也需要为它们创建新的迁移脚本。总而言之,维护工作非常繁琐。

数据模型影响

如前几节所述,将添加两个表:Deployables 和 Attributes

CREATE TABLE Deployables
  (
    id           INTEGER NOT NULL ,     /*Primary Key*/
    parent_id    INTEGER ,              /*Pointer to the parent deployable's primary key*/
    root_id      INTEGER ,              /*Pointer to the root deployable's primary key*/
    name         VARCHAR2 (32 BYTE) ,   /*Name of the deployable*/
    pcie_address VARCHAR2 (32 BYTE) ,   /*pcie address which can be used for passthrough*/
    uuid         VARCHAR2 (32 BYTE) ,   /*uuid v4 format for the deployable itself*/
    node_id      VARCHAR2 (32 BYTE) ,   /*uuid v4 format to identify which host this deployable is located*/
    board        VARCHAR2 (16 BYTE) ,   /*Identify the model of the deployable(e.g. KU115)*/
    vendor       VARCHAR2 (16 BYTE) ,   /*Identify the vendor of the deployable(e.g. Xilinx)*/
    version      VARCHAR2 (32 BYTE) ,   /*Identify the version of the deployable(e.g. 1.2a)*/
    type         VARCHAR2 (32) ,        /*Identify the type of the deployable(e.g. FPGA/PF/VF)*/
    assignable   CHAR (1) ,             /*Represent if the deployable can be assigned to users*/
    instance_id  VARCHAR2 (32 BYTE) ,   /*Represent which instance this deployable has been assigned to*/
    availability INTEGER NOT NULL,      /*enum type to represent the status of the deployable(e.g. acclocated/claimed)*/
    accelerator_id INTEGER NOT NULL     /*foreign key references to the accelerator table*/
  ) ;
ALTER TABLE Deployables ADD CONSTRAINT Deployables_PK PRIMARY KEY ( id ) ;
ALTER TABLE Deployables ADD CONSTRAINT Deployables_accelerators_FK FOREIGN KEY ( accelerator_id ) REFERENCES accelerators ( id ) ;


CREATE TABLE Attributes
  (
    id            INTEGER NOT NULL ,    /*Primary Key*/
    deployable_id INTEGER NOT NULL ,    /*foreign key references to the Deployables table*/
    KEY CLOB ,                          /*Attribute Key*/
    value CLOB ,                        /*Attribute Value*/
    parent_attribute_id INTEGER         /*Pointer to the parent attribute's primary key*/
  ) ;
ALTER TABLE Attributes ADD CONSTRAINT Attributes_PK PRIMARY KEY ( id ) ;
ALTER TABLE Attributes ADD CONSTRAINT Attributes_Deployables_FK FOREIGN KEY ( deployable_id ) REFERENCES Deployables ( id ) ON
DELETE CASCADE ;

RPC API 影响

需要添加两组 conductor API。一组用于物理功能,一组用于虚拟功能

物理功能 API

def physical_function_create(context, values)
def physical_function_get_all_by_filters(context, filters, sort_key='created_at', sort_dir='desc', limit=None, marker=None, columns_to_join=None)
def physical_function_update(context, uuid, values, expected=None)
def physical_function_destroy(context, uuid)

虚拟功能 API

def virtual_function_create(context, values)
def virtual_function_get_all_by_filters(context, filters, sort_key='created_at', sort_dir='desc', limit=None, marker=None, columns_to_join=None)
def virtual_function_update(context, uuid, values, expected=None)
def virtual_function_destroy(context, uuid)

REST API 影响

由于这些表未向用户公开用于修改/添加/删除,Cyborg 将仅添加两个额外的 REST API,以允许用户查询与可部署资源及其属性相关的信息。

检索 Deployable 信息的 API

Url: {base_url}/accelerators/deployable/{uuid}
Method: GET
URL Params:
    GET: uuid --> get deplyable by uuid

Data Params:
    None

Success Response:
    GET:
        Code: 200
        Content: { deployable: {id : 12, parent_id: 11, root_id: 10, ....}}

Error Response
    Code: 401 UNAUTHORIZED
    Content: { error : "Log in" }
    OR
    Code: 422 Unprocessable Entry
    Content: { error : "deployable uuid invalid" }

Sample Call:
    To get the deployable with uuid=2864a139-c2cd-4f9f-abf3-44eb3f09b83c
    $.ajax({
      url: "/accelerators/deployable/2864a139-c2cd-4f9f-abf3-44eb3f09b83c",
      dataType: "json",
      type : "get",
      success : function(r) {
        console.log(r);
      }
    });

检索带有过滤器/属性的 Deployables 列表的 API

Url: {base_url}/accelerators/deployable
Method: GET
URL Params:
    None

Data Params:
    k-v pairs for filtering

Success Response:
    GET:
        Code: 200
        Content: { deployables: [{id : 12, parent_id: 11, root_id: 10, ....}]}

Error Response
    Code: 401 UNAUTHORIZED
    Content: { error : "Log in" }
    OR
    Code: 422 Unprocessable Entry
    Content: { error : "deployable uuid invalid" }

Sample Call:
    To get a list of FPGAs with no bitstream loaded.
    $.ajax({
      url: "/accelerators/deployable",
      data: {
        "bitstream_id": None,
        "type": "FPGA"
      },
      dataType: "json",
      type : "get",
      success : function(r) {
        console.log(r);
      }
    });

检索 Deployable 属性信息的 API

Url: {base_url}/accelerators/deployable/{uuid}/attribute/{key}
Method: GET
URL Params:
    GET: uuid --> uuid for the associated deployable
         key  --> key for the associated deployable

Data Params:
    None

Success Response:
    GET:
        Code: 200
        Content: { attribute: {key : value}}

Error Response
    Code: 401 UNAUTHORIZED
    Content: { error : "Log in" }
    OR
    Code: 422 Unprocessable Entry
    Content: { error : "attirbute key invalid" }

Sample Call:
    To get the value of key=kpi for deployable with id=2864a139-c2cd-4f9f-abf3-44eb3f09b83c
    $.ajax({
      url: "/accelerators/deployable/2864a139-c2cd-4f9f-abf3-44eb3f09b83c/attribute/kpi",
      dataType: "json",
      type : "get",
      success : function(r) {
        console.log(r);
      }
    });

安全影响

通知影响

其他最终用户影响

性能影响

其他部署者影响

开发者影响

由于这项工作,开发人员将可以使用新的功能。

实现

负责人

主要负责人

刘丽 <liliu1@huawei.com>

工作项

  • 创建迁移脚本以向数据库添加两个表

  • 在 sqlalchemy 中创建模型以及相关的 conductor API

  • 创建相应的对象

  • 创建 Conductor API 以允许资源报告

依赖项

测试

  • 将添加单元测试以测试 Cyborg 通用驱动程序。

文档影响

记录 Cyborg 项目中的 FPGA 建模

参考资料

1

https://docs.openstack.org/nova/latest/user/placement.html

历史记录

修订

发布

描述

Queens

引入