UH-OH

It looks like you don’t have access to that feature yet

Contact sales to get upgraded to the full DevStudio experience.

UH-OH

It looks like you don't have access to that feature yet.

to select
to navigate
escto close
Chimera Compute Library (CCL) API ReferenceProcessor Elementwise (PE) Operations

Processor Elementwise (PE) Operations

Processor Elementwise (PE) Boolean Functions

The anyOf API provides an efficient way to evaluate a boolean condition across all cores in the architecture. The function returns a boolean value, true if the condition is satisfied by at least one core, and false otherwise.

This is effectively act as an “OR“ operation.

File: /src/core/epu_common.hppLines 140–147
  /**
   * @brief      Evaluate if any of the cores satisfy the condition.
   *
   * @param[in]  cond  The condition
   *
   * @return     true or false dependent on the conditions evaluation.
   */
  static bool anyOf(qVar_t<bool> cond) {

Examples

Example #1

Let's say we have a QB1 Chimera architecture (8x8 core array) and a tensor of shape <1, 1, 8, 8> with integer values. We want to check if any core in the architecture has a value equal to 10.

if(anyOf(qIn[tileIdx] == 10)) {
  qOut[tileIdx] = 10;
} else {
  qOut[tileIdx] = qIn[tileIdx] + 1;
}

When evaluating for left tile, the expression (anyOf(qIn[tileIdx] == 10)) will return FALSE as 10 is not present in any of the cores.

In contrast, when evaluating the right tile, the expression will return TRUE. This is because the values in two cores (marked in bold red) are equal to 10.

Example #2

File: /tests/static_data_tests/tile_any_of.cppLines 41–65
EPU_ENTRY void ifAnyTileTest(DdrTensorShape::ptrType ddrOutPtr) {
  initCycleCount();
  DdrTensorShape ddrOut(ddrOutPtr);
  MemAllocator   ocmMem;

  using WriteAccess = TensorAccessor<MinRoiDescriptor<DdrTensorShape, DefaultAxisGroup, Granularity::Square>>;
  auto                                     elsWrite = createGeneralWriteFlow<WriteAccess>(ddrOut, ocmMem);
  typename decltype(elsWrite)::MinRoiArray qOutput;

  qVar_t<std::int32_t> qData = (qRow<> * core_array::coreDim) + qCol<>;

  // Find which row 49 is on.
  if(qArrayCore) {
    for(std::int32_t row = 0; row < core_array::coreDim; row++) {
      /* For each row, search for any element that matches numToSearchFor
       * Upon a match, break from the loop.
       */
      if(anyOf(qRow<> == row && qData == numToSearchFor)) {
        qOutput[0] = row;
        break;
      }
    }
  }
  elsWrite.write(qOutput);
}

Example #3

This example demonstrates the usage of conditional logic with anyOf in a nested context.

File: /tests/static_data_tests/tile_any_all_nested.cppLines 38–70
EPU_ENTRY void tileAnyAllNested(DdrOutTensorShape::ptrType ddrOutPtr) {
  initCycleCount();
  DdrOutTensorShape ddrOut(ddrOutPtr);
  MemAllocator      ocmMem;

  qVar_t<std::int32_t> qData = (qRow<> * core_array::coreDim) + qCol<>;

  std::int32_t b = 2;

  if(!chimera::allOf(qData < core_array::coreDim)) {
    b = 4;
  }

  using WriteAccess = TensorAccessor<MinRoiDescriptor<DdrOutTensorShape, DefaultAxisGroup, Granularity::Square>>;
  auto                                     elsWrite = createGeneralWriteFlow<WriteAccess>(ddrOut, ocmMem);
  typename decltype(elsWrite)::MinRoiArray qOutput  = {0};

  // Ensure b has not been promoted to qVar by using it in a loop.
  for(std::int32_t i = 0; i < b; i++) {
    qOutput[0] += 1;
  }

  // qOutput should be uniform 4's at this point
  if(qRow<> < qOutput[0]) {
    // Only cores in rows less than 4 should execute the following.
    if(chimera::anyOf(qOutput[0] < qCol<>)) {
      qOutput[0] = 7;
    }
  }

  // Write tile out to Ddr
  elsWrite.write(qOutput);
}

The allOf API provides an efficient way to evaluate a boolean condition across all cores in the architecture. The function returns a boolean value, true if the condition is satisfied by all the cores, and false otherwise.

Essentially, the allOf API functions as an "AND" operation.

File: /src/core/epu_common.hppLines 154–161
  /**
   * @brief      Evaluate if all of the cores satisfy the condition.
   *
   * @param[in]  cond  The condition
   *
   * @return     true or false dependent on the conditions evaluation.
   */
  static bool allOf(qVar_t<bool> cond) {

Examples

Example #1

Let's say we have a QB1 Chimera architecture (8x8 PE array) and a tensor of shape <1, 1, 8, 8> with integer values. We want to check if all cores have values that do not exceed a certain threshold (e.g., 100) and perform different operations based on the evaluation of this condition.

std::int32_t threshold = 100;
if(allOf(qData[tileIdx] <= threshold)) {
  normalOperation(qData[tileIdx]);
} else {
  specialOperation(qData[tileIdx]);
}

Example #2

In this example, we count tiles where the numbers are less than a specific threshold.

File: /tests/static_data_tests/tile_all_of.cppLines 44–65
EPU_ENTRY void ifAllTileTest(DdrInpTensorShape::ptrType ddrInpPtr, DdrOutTensorShape::ptrType ddrOutPtr) {
  initCycleCount();
  DdrInpTensorShape ddrInp(ddrInpPtr);
  DdrOutTensorShape ddrOut(ddrOutPtr);

  MemAllocator ocmMem;

  using ReadAccess  = TensorAccessor<MinRoiDescriptor<DdrInpTensorShape, DefaultAxisGroup, Granularity::Square>>;
  using WriteAccess = TensorAccessor<MinRoiDescriptor<DdrOutTensorShape, DefaultAxisGroup, Granularity::Square>>;
  auto                                     elsRead  = createGeneralReadFlow<ReadAccess>(ddrInp, ocmMem);
  auto                                     elsWrite = createGeneralWriteFlow<WriteAccess>(ddrOut, ocmMem);
  auto                                     qInput   = elsRead.read();
  typename decltype(elsWrite)::MinRoiArray qOutput  = {0};

  for(std::int32_t i = 0; i < DdrInpTensorShape::NUM_TILES; i++) {
    if(allOf(qInput[i] < lessThan)) {
      qOutput[0] += 1;
    }
  }

  elsWrite.write(qOutput);
}

When evaluating the left tile using the expression

File: /tests/static_data_tests/tile_all_of.cppSymbol: (allOf(qInput[i] < lessThan))
(allOf(qInput[i] < lessThan))
, the function will return TRUE because all of the values are less than the threshold (100).

In contrast, for the right tile, when evaluating the same expression (allOf(qData[tileIdx] <= threshold)), the function will return FALSE because values at some cores (marked in bold red) exceed the threshold.

Table of Contents


© Copyright 2026 Quadric All Rights Reserved • Privacy Policy
This documentation is preliminary and confidential. It is subject to change. Quadric does not give any warranty express or implied that the contents will be complete or accurate or up to date. The company shall not be liable for any loss, actions, claims, proceedings, demands or costs or damages whatsoever or howsoever caused arising directly or indirectly in connection with or arising out of the use of this material.

Sign in to your account

Don't have an account? Create an Account
By signing in, you are agreeing to our Terms of Use and Privacy Policy.

Develop.

Simulate.

Profile.

Collaborate.

We use cookies to enhance your browsing experience, and analyze our traffic.
By clicking "Accept All", you consent to our use of cookies.