C++ Run-time Library
Loading...
Searching...
No Matches
kernel.h
Go to the documentation of this file.
1// Copyright 2018 Delft University of Technology
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <arrow/api.h>
18#include <fletcher/fletcher.h>
19#include <cstdint>
20#include <vector>
21#include <memory>
22
23#include "fletcher/context.h"
24#include "fletcher/platform.h"
25
26namespace fletcher {
27
29class Kernel {
30 public:
35 explicit Kernel(std::shared_ptr<Context> context);
36
42 bool ImplementsSchemaSet(const std::vector<std::shared_ptr<arrow::Schema>> &schema_set);
43
49
57 Status SetRange(size_t recordbatch_index, int32_t first, int32_t last);
58
64 Status SetArguments(const std::vector<uint32_t> &arguments);
65
71
77 Status GetStatus(uint32_t *status_out);
78
85 Status GetReturn(uint32_t *ret0, uint32_t *ret1 = nullptr);
86
92 Status PollUntilDoneInterval(unsigned int poll_interval_usec);
93
101
103 std::shared_ptr<Context> context();
104
110
111 // Default control and status values:
113 uint32_t ctrl_start = 1ul << FLETCHER_REG_CONTROL_START;
115 uint32_t ctrl_reset = 1ul << FLETCHER_REG_CONTROL_RESET;
117 uint32_t done_status = 1ul << FLETCHER_REG_STATUS_DONE;
119 uint32_t done_status_mask = 1ul << FLETCHER_REG_STATUS_DONE;
120
121 protected:
123 bool metadata_written = false;
125 std::shared_ptr<Context> context_;
126};
127
128} // namespace fletcher
The Kernel class is used to manage the computational kernel of the accelerator.
Definition kernel.h:29
std::shared_ptr< Context > context()
Return the context of this Kernel.
std::shared_ptr< Context > context_
The context that this kernel should operate on.
Definition kernel.h:125
Status WriteMetaData()
Write RecordBatch metadata from the Context to the Kernel MMIO registers.
Status PollUntilDone()
Poll the done flag of the status register for assertion (blocking). Polls at maximum speed.
Status PollUntilDoneInterval(unsigned int poll_interval_usec)
Poll (blocking) the done flag of the status register for assertion with an interval.
Status GetStatus(uint32_t *status_out)
Read the status register of the Kernel.
bool ImplementsSchemaSet(const std::vector< std::shared_ptr< arrow::Schema > > &schema_set)
Returns true if the kernel implements an operation over a set of arrow::Schemas. Not implemented.
uint32_t done_status
Status register done value.
Definition kernel.h:117
bool metadata_written
Whether RecordBatch metadata was written.
Definition kernel.h:123
Status GetReturn(uint32_t *ret0, uint32_t *ret1=nullptr)
Read the return registers of the Kernel. If ret1 is nullptr, REG_RETURN1 is ignored.
Status SetRange(size_t recordbatch_index, int32_t first, int32_t last)
Set the first (inclusive) and last (exclusive) row to process of some RecordBatch.
uint32_t ctrl_reset
Control register reset command value.
Definition kernel.h:115
uint32_t ctrl_start
Control register start command value.
Definition kernel.h:113
uint32_t done_status_mask
Status register done mask bits.
Definition kernel.h:119
Status Start()
Start the kernel.
Status Reset()
Reset the Kernel.
Kernel(std::shared_ptr< Context > context)
Construct a new kernel that can operate within a specific context.
Status SetArguments(const std::vector< uint32_t > &arguments)
Set custom arguments to the kernel. Writes consecutive MMIO registers starting from custom register o...
Contains all Fletcher classes and functions for use in run-time applications.
Definition api.h:34
Status return value of all Fletcher run-time functions.
Definition status.h:25