#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include "pba.h"
#include "SparseBundleCU.h"
#include "ProgramCU.h"
Go to the source code of this file.
|
| #define | CHECK_VEC(v1, v2) |
| |
| #define | DEBUG_FUNCN(v, func, input, N) |
| |
| #define | DEBUG_FUNC(v, func, input) DEBUG_FUNCN(v, func, input, 2) |
| |
| #define | REPORT_ALLOCATION(NAME) |
| |
| #define | ASSERT_ALLOCATION(NAME) |
| |
| #define | CHECK_ALLOCATION(NAME) |
| |
| #define | ALLOCATE_REQUIRED_DATA(NAME, num, channels) |
| |
| #define | ALLOCATE_OPTIONAL_DATA(NAME, num, channels, option) |
| |
| #define | PROFILE_(A, B) |
| |
| #define | PROFILE(A, B) PROFILE_(#A, A B) |
| |
| #define | PROXILE(A, B) PROFILE_(A, B) |
| |
◆ ALLOCATE_OPTIONAL_DATA
| #define ALLOCATE_OPTIONAL_DATA |
( |
|
NAME, |
|
|
|
num, |
|
|
|
channels, |
|
|
|
option |
|
) |
| |
Value: if (option) { \
option =
NAME.InitTexture(num, 1, channels); \
CHECK_ALLOCATION(NAME); \
} else { \
NAME.InitTexture(0, 0, 0); \
}
Definition at line 399 of file SparseBundleCU.cpp.
◆ ALLOCATE_REQUIRED_DATA
| #define ALLOCATE_REQUIRED_DATA |
( |
|
NAME, |
|
|
|
num, |
|
|
|
channels |
|
) |
| |
Value: { \
success &=
NAME.InitTexture(num, 1, channels); \
ASSERT_ALLOCATION(NAME); \
}
Definition at line 393 of file SparseBundleCU.cpp.
◆ ASSERT_ALLOCATION
| #define ASSERT_ALLOCATION |
( |
|
NAME | ) |
|
Value: if (!success) { \
std::cerr << "WARNING: failed to allocate " \
<< (__verbose_allocation ? #
NAME "; size = " :
"") \
<< (total_sz / 1024 / 1024) << "MB + " \
<< (
NAME.GetRequiredSize() / 1024 / 1024) <<
"MB\n"; \
return false; \
} else { \
total_sz +=
NAME.GetDataSize(); \
REPORT_ALLOCATION(NAME); \
}
Definition at line 371 of file SparseBundleCU.cpp.
◆ CHECK_ALLOCATION
| #define CHECK_ALLOCATION |
( |
|
NAME | ) |
|
Value: if (
NAME.GetDataSize() == 0 &&
NAME.GetRequiredSize() > 0) { \
ClearPreviousError(); \
std::cerr <<
"WARNING: unable to allocate " #
NAME ": " \
<< (
NAME.GetRequiredSize() / 1024 / 1024) <<
"MB\n"; \
} else { \
total_sz +=
NAME.GetDataSize(); \
REPORT_ALLOCATION(NAME); \
}
Definition at line 383 of file SparseBundleCU.cpp.
◆ CHECK_VEC
| #define CHECK_VEC |
( |
|
v1, |
|
|
|
v2 |
|
) |
| |
Value: for (size_t j = 0; j < v1.size(); ++j) { \
if (v1[j] != v2[j]) { \
different++; \
std::cout << i << ' ' << j << ' ' << v1[j] << ' ' << v2[j] << '\n'; \
} \
}
Definition at line 51 of file SparseBundleCU.cpp.
◆ DEBUG_FUNC
| #define DEBUG_FUNC |
( |
|
v, |
|
|
|
func, |
|
|
|
input |
|
) |
| DEBUG_FUNCN(v, func, input, 2) |
◆ DEBUG_FUNCN
| #define DEBUG_FUNCN |
( |
|
v, |
|
|
|
func, |
|
|
|
input, |
|
|
|
N |
|
) |
| |
Value: if (__debug_pba && v.IsValid()) { \
vector<float> buf(v.GetLength()), buf_(v.GetLength()); \
for (int i = 0; i < N; ++i) { \
int different = 0; \
if (i > 0) { \
v.CopyToHost(&buf_[0]); \
CHECK_VEC(buf, buf_); \
} else { \
v.CopyToHost(&buf[0]); \
} \
if (different != 0) \
std::cout << #func << " : " << i << " : " << different << '\n'; \
} \
}
Definition at line 58 of file SparseBundleCU.cpp.
◆ PROFILE
| #define PROFILE |
( |
|
A, |
|
|
|
B |
|
) |
| PROFILE_(#A, A B) |
◆ PROFILE_
| #define PROFILE_ |
( |
|
A, |
|
|
|
B |
|
) |
| |
Value: BundleTimerStart(TIMER_PROFILE_STEP); \
for (int i = 0; i < repeat; ++i) { \
B; \
FinishWorkCUDA(); \
} \
BundleTimerSwitch(TIMER_PROFILE_STEP); \
std::cout << std::setw(24) << A << ": " \
<< (BundleTimerGet(TIMER_PROFILE_STEP) / repeat) << "\n";
Definition at line 1779 of file SparseBundleCU.cpp.
◆ PROXILE
◆ REPORT_ALLOCATION
| #define REPORT_ALLOCATION |
( |
|
NAME | ) |
|
Value: if (__verbose_allocation &&
NAME.GetDataSize() > 1024) \
std::cout << (
NAME.GetDataSize() > 1024 * 1024 \
?
NAME.GetDataSize() / 1024 / 1024 \
:
NAME.GetDataSize() / 1024) \
<< (
NAME.GetDataSize() > 1024 * 1024 ?
"MB" :
"KB") \
<< "\t allocated for " #NAME "\n";
Definition at line 363 of file SparseBundleCU.cpp.