Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ864
Page ↗
Q864FWNVIDIAASIC interview problem

Count coalesced memory segments

TechniquesFWValidationDebugCountCoalesced
DifficultyMedium
TopicFirmware
LanguageC++
Requirements4 checkpoints
01

Problem

A validation model must count the 32-byte memory segments touched by one warp's active four-byte loads. Write the C++ function that returns the number of distinct aligned segments.

Starting declarationC++
int segment_count(const uint32_t addr[32], uint32_t active_mask);

Example input and output

Use this case to check your interpretation
Input
Activate aligned addresses 0x100, 0x104, and 0x11C in three warp lanes.
Output
segment_count returns 1.
Explanation

Masking each address to a 32-byte base produces the same segment address 0x100.

02

Requirements (4)

  • Each active lane performs one four-byte load and every active address is four-byte aligned.
  • A segment is identified by addr[lane] & ~uint32_t(31); count each distinct segment once.
  • Return zero for active_mask=0; addr may be NULL only in that case, otherwise return -1 for NULL or misalignment.
  • Use fixed storage only, with no allocation and no reads from inactive lanes.