58 template <RunData_t T>
72 const std::array<unsigned int, 2>& width_height,
73 std::size_t offset_into_arrays,
74 unsigned int level_num,
87 const std::array<unsigned int, 2>& width_height,
88 std::size_t offset_into_arrays,
89 unsigned int level_num,
90 unsigned int bytes_align_memory);
140 const std::array<unsigned int, 2>& width_height_level,
141 unsigned int num_possible_disparities)
const;
154 const std::array<unsigned int, 2>& width_height_bottom_level,
155 unsigned int num_possible_disparities,
156 unsigned int num_levels,
166 return level_properties_;
173 template <RunData_t T>
175 const std::array<unsigned int, 2>& width_height,
176 std::size_t offset_into_arrays,
177 unsigned int level_num,
180 level_properties_.width_level_ = width_height[0];
181 level_properties_.height_level_ = width_height[1];
182 level_properties_.level_num_ = level_num;
183 level_properties_.offset_into_arrays_= offset_into_arrays;
184 level_properties_.bytes_align_memory_ =
186 level_properties_.width_checkerboard_level_ =
187 CheckerboardWidth(level_properties_.width_level_);
188 level_properties_.padded_width_checkerboard_level_ =
189 PaddedCheckerboardWidth(level_properties_.width_checkerboard_level_);
193 template <RunData_t T>
195 const std::array<unsigned int, 2>& width_height,
196 std::size_t offset_into_arrays,
197 unsigned int level_num,
198 unsigned int bytes_align_memory)
200 level_properties_.width_level_ = width_height[0];
201 level_properties_.height_level_ = width_height[1];
202 level_properties_.level_num_ = level_num;
203 level_properties_.offset_into_arrays_ = offset_into_arrays;
204 level_properties_.bytes_align_memory_ = bytes_align_memory;
205 level_properties_.width_checkerboard_level_ =
206 CheckerboardWidth(level_properties_.width_level_);
207 level_properties_.padded_width_checkerboard_level_ =
208 PaddedCheckerboardWidth(level_properties_.width_checkerboard_level_);
213 template <RunData_t T>
216 const std::size_t offset_next_level =
217 level_properties_.offset_into_arrays_ +
218 NumDataInBpArrays(num_disparity_values);
220 {(
unsigned int)std::ceil((
float)level_properties_.width_level_ / 2.0f),
221 (
unsigned int)std::ceil((
float)level_properties_.height_level_ / 2.0f)},
223 (level_properties_.level_num_ + 1),
224 level_properties_.bytes_align_memory_);
230 template <RunData_t T>
232 unsigned int num_disparity_values)
const
234 return NumDataForAlignedMemoryAtLevel(
235 {level_properties_.width_level_, level_properties_.height_level_},
236 num_disparity_values);
239 template <RunData_t T>
241 const std::array<unsigned int, 2>& width_height_level,
242 unsigned int num_possible_disparities)
const
244 const std::size_t numDataAtLevel =
245 (std::size_t)PaddedCheckerboardWidth(CheckerboardWidth(width_height_level[0])) *
246 ((std::size_t)width_height_level[1]) *
247 (std::size_t)num_possible_disparities;
248 std::size_t numBytesAtLevel = numDataAtLevel *
sizeof(T);
250 if ((numBytesAtLevel % level_properties_.bytes_align_memory_) == 0) {
251 return numDataAtLevel;
255 (level_properties_.bytes_align_memory_ -
256 (numBytesAtLevel % level_properties_.bytes_align_memory_));
257 return (numBytesAtLevel /
sizeof(T));
261 template <RunData_t T>
263 unsigned int width_level)
const
265 return (
unsigned int)std::ceil(((
float)width_level) / 2.0f);
268 template <RunData_t T>
270 unsigned int checkerboard_width)
const
272 size_t num_data_align_width = level_properties_.bytes_align_memory_ /
sizeof(T);
274 return ((checkerboard_width % num_data_align_width) == 0) ?
276 (checkerboard_width +
277 (num_data_align_width - (checkerboard_width % num_data_align_width)));
281 template <RunData_t T>
283 const std::array<unsigned int, 2>& width_height_bottom_level,
284 unsigned int num_possible_disparities,
285 unsigned int num_levels,
288 BpLevel<T> curr_level_properties(width_height_bottom_level, 0, 0, acceleration);
289 std::size_t total_data =
291 for (
unsigned int curr_level = 1; curr_level < num_levels; curr_level++)
293 curr_level_properties = curr_level_properties.
NextBpLevel(num_possible_disparities);
Declares and defines structure that stores settings for current implementation run as well as functio...
Define constraints for data type in processing.
Class to store and retrieve properties of a bp processing level including a data type specified as a ...
BpLevel(const std::array< unsigned int, 2 > &width_height, std::size_t offset_into_arrays, unsigned int level_num, run_environment::AccSetting acc_setting)
Construct a new BpLevel object with specified height/wdith, offset into data/message arrays,...
std::size_t NumDataInBpArrays(unsigned int num_disparity_values) const
Get the amount of data in each BP array (data cost/messages for each checkerboard) at the current lev...
const beliefprop::BpLevelProperties & LevelProperties() const
Return level properties as const reference to avoid copying and not allow it to be modified.
unsigned int CheckerboardWidth(unsigned int width_level) const
Get width of checkerboard to use in bp processing at level. Checkerboard width is half of the width ...
unsigned int PaddedCheckerboardWidth(unsigned int checkerboard_width) const
Get width of padded checkerboard to use in bp processing at level. Padding can add additional width ...
std::size_t NumDataForAlignedMemoryAtLevel(const std::array< unsigned int, 2 > &width_height_level, unsigned int num_possible_disparities) const
Get count of total data needed for bp processing at level.
BpLevel NextBpLevel(unsigned int num_disparity_values) const
Get bp level properties for next (higher) level in hierarchy that processes data with half width/heig...
static std::size_t TotalDataForAlignedMemoryAllLevels(const std::array< unsigned int, 2 > &width_height_bottom_level, unsigned int num_possible_disparities, unsigned int num_levels, run_environment::AccSetting acceleration)
Static function to get count of total data needed for bp processing at all levels.
Namespace for enums, constants, structures, and functions specific to belief propagation processing.
AccSetting
Enum for acceleration setting.
unsigned int GetBytesAlignMemory(AccSetting accel_setting)
POD struct to store bp level data. Struct can be passed to global CUDAs kernel so needs to take restr...
unsigned int height_level_
unsigned int width_checkerboard_level_
unsigned int bytes_align_memory_
unsigned int width_level_
std::size_t offset_into_arrays_
unsigned int padded_width_checkerboard_level_