P4C
The P4 Compiler
Loading...
Searching...
No Matches
ReductionOrInfo Struct Reference

#include <reduction_or.h>

Public Types

using SaluReductionOrGroup = std::map<cstring, ordered_set<const IR::MAU::StatefulAlu *>>
 
using TblReductionOrGroup = std::map<cstring, ordered_set<const IR::MAU::Table *>>
 

Public Member Functions

void clear ()
 
bool is_reduction_or (const IR::MAU::Instruction *, const IR::MAU::Table *, cstring &red_or_key) const
 

Public Attributes

SaluReductionOrGroup salu_reduction_or_group
 
TblReductionOrGroup tbl_reduction_or_group
 

Detailed Description

A reduction or is an optimization where an binary OR operation is implemented by ORing action data on the action data bus, and using the results of this in an ALU operation. The action data bus is a large OXBar, so the sending two action data sources to the same bytes on the action bus results in the ORing of these two sources. This can ORed by up to as many sources are possible per stage.

The standard use case for this is a bloom filter. In order to reduce the dependency chain, multiple stateful ALUs are ORed to the same place in the action data bus. The current way this is delineated is through an extra property on a stateful ALU, "reduction_or_group". Stateful ALUs that are in the same reduction_or_group use this optimization, and thus have no penalty.

TODO: In order to fully gain the power of this optimization, instead of looking for a "reduction_or_group", the compiler could do this lookup automatically based on the P4 code, and the use of stateful ALU outputs in OR based AssignmentStatements. This is a holdover until we have the time to implement this.

Member Function Documentation

◆ is_reduction_or()

bool ReductionOrInfo::is_reduction_or ( const IR::MAU::Instruction * instr,
const IR::MAU::Table * tbl,
cstring & reduction_or_key ) const

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0 A check to see if an instruction is part of a reduction or. The operation is part of a binary OR, i.e.:

f = f | salu.execute();

where the stateful ALU is part of a reduction or group found in the map. This will return the name of the key used by the stateful ALU.