Commit 40f92327 by Tobias Fuchs

Fixed warnings returned from recent version of cpplint

parent 77016ad7
......@@ -46,8 +46,7 @@ class ValueComparisonFunction{
int operator()(ElementType element) {
if (element == value_) {
return 1;
}
else {
} else {
return 0;
}
}
......@@ -69,8 +68,7 @@ class FunctionComparisonFunction{
int operator()(ElementType element) {
if (function_(element)) {
return 1;
}
else {
} else {
return 0;
}
}
......
......@@ -41,14 +41,12 @@ namespace internal {
template<typename RAI, typename Function>
class ForEachFunctor {
private:
typedef ForEachFunctor<RAI, Function> self_t;
public:
/**
* Constructs a for-each functor with arguments.
*/
ForEachFunctor(size_t chunk_first, size_t chunk_last, Function unary,
const embb::mtapi::ExecutionPolicy& policy,
const embb::mtapi::ExecutionPolicy& policy,
const BlockSizePartitioner<RAI>& partitioner)
: chunk_first_(chunk_first), chunk_last_(chunk_last),
unary_(unary), policy_(policy), partitioner_(partitioner) {
......@@ -63,15 +61,14 @@ class ForEachFunctor {
for (RAI it = first; it != last; ++it) {
unary_(*it);
}
}
else {
} else {
// Recurse further:
size_t chunk_split_index = (chunk_first_ + chunk_last_) / 2;
// Split chunks into left / right branches:
self_t functor_l(chunk_first_,
self_t functor_l(chunk_first_,
chunk_split_index,
unary_, policy_, partitioner_);
self_t functor_r(chunk_split_index + 1,
self_t functor_r(chunk_split_index + 1,
chunk_last_,
unary_, policy_, partitioner_);
mtapi::Task task_l = mtapi::Node::GetInstance().Spawn(
......@@ -88,6 +85,9 @@ class ForEachFunctor {
}
private:
typedef ForEachFunctor<RAI, Function> self_t;
private:
size_t chunk_first_;
size_t chunk_last_;
Function unary_;
......@@ -123,8 +123,8 @@ void ForEachRecursive(RAI first, RAI last, Function unary,
}
BlockSizePartitioner<RAI> partitioner(first, last, block_size);
ForEachFunctor<RAI, Function> functor(0,
partitioner.Size() - 1,
ForEachFunctor<RAI, Function> functor(0,
partitioner.Size() - 1,
unary, policy, partitioner);
mtapi::Task task = node.Spawn(mtapi::Action(
base::MakeFunction(functor,
......
......@@ -171,7 +171,7 @@ void MergeSort(
assert(distance >= 0);
if (block_size == 0) {
block_size= (static_cast<size_t>(distance) / node.GetCoreCount());
block_size = (static_cast<size_t>(distance) / node.GetCoreCount());
if (block_size == 0)
block_size = 1;
}
......
......@@ -195,7 +195,7 @@ void QuickSort(RAI first, RAI last, ComparisonFunction comparison,
typename std::iterator_traits<RAI>::difference_type distance = last - first;
assert(distance > 0);
if (block_size == 0) {
block_size= (static_cast<size_t>(distance) / node.GetCoreCount());
block_size = (static_cast<size_t>(distance) / node.GetCoreCount());
if (block_size == 0)
block_size = 1;
}
......
......@@ -41,10 +41,6 @@ namespace internal {
template<typename RAI, typename ReturnType, typename ReductionFunction,
typename TransformationFunction>
class ReduceFunctor {
private:
typedef ReduceFunctor<RAI, ReturnType,
ReductionFunction,
TransformationFunction> self_t;
public:
ReduceFunctor(size_t chunk_first, size_t chunk_last,
ReturnType neutral,
......@@ -53,7 +49,7 @@ class ReduceFunctor {
const embb::mtapi::ExecutionPolicy& policy,
const BlockSizePartitioner<RAI>& partitioner,
ReturnType& result)
: chunk_first_(chunk_first), chunk_last_(chunk_last), neutral_(neutral),
: chunk_first_(chunk_first), chunk_last_(chunk_last), neutral_(neutral),
reduction_(reduction), transformation_(transformation), policy_(policy),
partitioner_(partitioner), result_(result) {
}
......@@ -69,8 +65,7 @@ class ReduceFunctor {
result = reduction_(result, transformation_(*it));
}
result_ = result;
}
else {
} else {
// Recurse further:
size_t chunk_split_index = (chunk_first_ + chunk_last_) / 2;
// Split chunks into left / right branches:
......@@ -94,7 +89,7 @@ class ReduceFunctor {
mtapi::Task task_r = mtapi::Node::GetInstance().Spawn(
mtapi::Action(
base::MakeFunction(
functor_r, &self_t::Action),
functor_r, &self_t::Action),
policy_));
task_l.Wait(MTAPI_INFINITE);
task_r.Wait(MTAPI_INFINITE);
......@@ -103,6 +98,11 @@ class ReduceFunctor {
}
private:
typedef ReduceFunctor<RAI, ReturnType,
ReductionFunction,
TransformationFunction> self_t;
private:
size_t chunk_first_;
size_t chunk_last_;
ReturnType neutral_;
......@@ -145,17 +145,16 @@ ReturnType ReduceRecursive(RAI first, RAI last, ReturnType neutral,
"Number of computation tasks required in reduction would "
"exceed MTAPI maximum number of tasks");
}
typedef ReduceFunctor<RAI, ReturnType, ReductionFunction,
TransformationFunction> Functor;
BlockSizePartitioner<RAI> partitioner(first, last, block_size);
ReturnType result = neutral;
Functor functor(0,
partitioner.Size() - 1,
neutral,
reduction, transformation,
neutral,
reduction, transformation,
policy,
partitioner,
partitioner,
result);
mtapi::Task task = node.Spawn(
mtapi::Action(base::MakeFunction(
......
......@@ -45,7 +45,7 @@ class ScanFunctor {
ReturnType neutral, ScanFunction scan,
TransformationFunction transformation,
const embb::mtapi::ExecutionPolicy& policy,
const BlockSizePartitioner<RAIIn>& partitioner,
const BlockSizePartitioner<RAIIn>& partitioner,
ReturnType* tree_values, size_t node_id,
bool going_down)
: policy_(policy), chunk_first_(chunk_first), chunk_last_(chunk_last),
......@@ -72,15 +72,13 @@ class ScanFunctor {
*iter_out = result;
}
SetTreeValue(result);
}
else {
} else {
// Second pass
for (; iter_in != last_in; ++iter_in, ++iter_out) {
*iter_out = scan_(parent_value_, *iter_out);
}
}
}
else {
} else {
// recurse further
size_t chunk_split_index = (chunk_first_ + chunk_last_) / 2;
// Split chunks into left / right branches:
......@@ -99,14 +97,14 @@ class ScanFunctor {
// Advance output iterator of right branch:
ChunkDescriptor<RAIIn> chunk_left = partitioner_[chunk_first_];
ChunkDescriptor<RAIIn> chunk_right = partitioner_[chunk_split_index + 1];
long long dist = std::distance(chunk_left.GetFirst(), chunk_right.GetFirst());
std::advance(functor_r.output_iterator_, dist);
std::advance(functor_r.output_iterator_,
std::distance(chunk_left.GetFirst(), chunk_right.GetFirst()));
if (!is_first_pass_) {
functor_l.parent_value_ = parent_value_;
functor_r.parent_value_ = functor_l.GetTreeValue() + parent_value_;
}
// Spawn tasks to recurse:
mtapi::Node& node = mtapi::Node::GetInstance();
mtapi::Node& node = mtapi::Node::GetInstance();
mtapi::Task task_l = node.Spawn(
mtapi::Action(
base::MakeFunction(functor_l, &ScanFunctor::Action),
......@@ -149,8 +147,7 @@ class ScanFunctor {
void SetID(int branch) {
if (branch == LEFT) {
node_id_ = 2 * node_id_ + 1;
}
else if (branch == RIGHT) {
} else if (branch == RIGHT) {
node_id_ = 2 * node_id_ + 2;
}
}
......@@ -198,9 +195,9 @@ void ScanIteratorCheck(RAIIn first, RAIIn last, RAIOut output_iterator,
TransformationFunction> Functor;
BlockSizePartitioner<RAIIn> partitioner_down(first, last, block_size);
Functor functor_down(0, partitioner_down.Size() - 1, output_iterator, neutral,
scan, transformation, policy, partitioner_down, values, 0,
true);
Functor functor_down(0, partitioner_down.Size() - 1, output_iterator,
neutral, scan, transformation, policy, partitioner_down,
values, 0, true);
mtapi::Task task_down = node.Spawn(mtapi::Action(base::MakeFunction(
functor_down, &Functor::Action),
policy));
......@@ -208,9 +205,9 @@ void ScanIteratorCheck(RAIIn first, RAIIn last, RAIOut output_iterator,
// Second pass. Gives to each leaf the part of the prefix missing
BlockSizePartitioner<RAIIn> partitioner_up(first, last, block_size);
Functor functor_up(0, partitioner_up.Size() - 1, output_iterator, neutral,
scan, transformation, policy, partitioner_up, values, 0,
false);
Functor functor_up(0, partitioner_up.Size() - 1, output_iterator,
neutral, scan, transformation, policy, partitioner_up,
values, 0, false);
mtapi::Task task_up = node.Spawn(mtapi::Action(base::MakeFunction(
functor_up, &Functor::Action),
policy));
......
......@@ -59,8 +59,8 @@ CountTest::CountTest() {
void CountTest::TestDataStructures() {
using embb::algorithms::Count;
const int size =10;
int array[] = {10, 20, 30, 30, 20, 10, 10, 20, 20, 20};
const int size = 10;
int array[] = { 10, 20, 30, 30, 20, 10, 10, 20, 20, 20 };
std::vector<int> vector(array, array + size);
std::deque<int> deque(array, array + size);
const std::vector<int> const_vector(array, array + size);
......@@ -73,8 +73,8 @@ void CountTest::TestDataStructures() {
void CountTest::TestCountIf() {
using embb::algorithms::CountIf;
const int size =10;
int array[] = {10, 21, 30, 31, 20, 11, 10, 21, 20, 20};
const int size = 10;
int array[] = { 10, 21, 30, 31, 20, 11, 10, 21, 20, 20 };
PT_EXPECT_EQ(CountIf(array, array + size, IsEven()), 6);
PT_EXPECT_EQ(CountIf(array, array + size, &IsEvenFunction), 6);
}
......
......@@ -105,4 +105,4 @@ typedef pthread_cond_t embb_condition_t;
} /* Close extern "C" { */
#endif
#endif /* EMBB_BASE_C_INTERNAL_PLATFORM_H_ */
#endif // EMBB_BASE_C_INTERNAL_PLATFORM_H_
......@@ -81,4 +81,4 @@ class AllocTest : public partest::TestCase {
} // namespace base
} // namespace embb
#endif /* BASE_C_TEST_ALLOC_TEST_H_ */
#endif // BASE_C_TEST_ALLOC_TEST_H_
......@@ -65,4 +65,4 @@ class ConditionVarTest : public partest::TestCase {
} // namespace base
} // namespace embb
#endif /* BASE_C_TEST_CONDITION_VAR_TEST_H_ */
#endif // BASE_C_TEST_CONDITION_VAR_TEST_H_
......@@ -51,4 +51,4 @@ class CoreSetTest : public partest::TestCase {
} // namespace base
} // namespace embb
#endif /* BASE_C_TEST_CORE_SET_TEST_H_ */
#endif // BASE_C_TEST_CORE_SET_TEST_H_
......@@ -97,4 +97,4 @@ class CounterTest : public partest::TestCase {
} // namespace base
} // namespace embb
#endif /* BASE_C_TEST_COUNTER_TEST_H_ */
#endif // BASE_C_TEST_COUNTER_TEST_H_
......@@ -73,4 +73,4 @@ class DurationTest : public partest::TestCase {
} // namespace base
} // namespace embb
#endif /* BASE_C_TEST_DURATION_TEST_H_ */
#endif // BASE_C_TEST_DURATION_TEST_H_
......@@ -78,4 +78,4 @@ int ThreadStart(void* arg);
#endif /* BASE_C_TEST_THREAD_INDEX_TEST_H_ */
#endif // BASE_C_TEST_THREAD_INDEX_TEST_H_
......@@ -61,4 +61,4 @@ class ThreadSpecificStorageTest : public partest::TestCase {
#endif /* BASE_C_TEST_THREAD_SPECIFIC_STORAGE_TEST_H_ */
#endif // BASE_C_TEST_THREAD_SPECIFIC_STORAGE_TEST_H_
......@@ -66,4 +66,4 @@ int ThreadStartFunction(void* arg);
} // namespace base
} // namespace embb
#endif /* BASE_C_TEST_THREAD_TEST_H_ */
#endif // BASE_C_TEST_THREAD_TEST_H_
......@@ -53,4 +53,4 @@ class TimeTest : public partest::TestCase {
#endif /* BASE_C_TEST_TIME_TEST_H_ */
#endif // BASE_C_TEST_TIME_TEST_H_
......@@ -201,4 +201,4 @@ class CoreSet {
#endif /* EMBB_BASE_CORE_SET_H_ */
#endif // EMBB_BASE_CORE_SET_H_
......@@ -522,4 +522,4 @@ class Nanoseconds : public Tick {
#include <embb/base/internal/duration-inl.h>
#endif /* EMBB_BASE_DURATION_H_ */
#endif // EMBB_BASE_DURATION_H_
......@@ -276,4 +276,4 @@ class ErrorException : public Exception {
} // namespace base
} // namespace embb
#endif /* EMBB_BASE_EXCEPTIONS_H_ */
#endif // EMBB_BASE_EXCEPTIONS_H_
......@@ -112,4 +112,4 @@ Duration<Tick>::Duration(const embb_duration_t& duration) : rep_() {
} // namespace base
} // namespace embb
#endif /* EMBB_BASE_INTERNAL_DURATION_INL_H_ */
#endif // EMBB_BASE_INTERNAL_DURATION_INL_H_
......@@ -116,4 +116,4 @@ bool UniqueLock<Mutex>::OwnsLock() const {
} // namespace base
} // namespace embb
#endif /* EMBB_BASE_INTERNAL_MUTEX_INL_H_ */
#endif // EMBB_BASE_INTERNAL_MUTEX_INL_H_
......@@ -107,4 +107,4 @@ std::basic_ostream<CharT, Traits>&
} // namespace base
} // namespace embb
#endif /* EMBB_BASE_INTERNAL_THREAD_INL_H_ */
#endif // EMBB_BASE_INTERNAL_THREAD_INL_H_
......@@ -103,4 +103,4 @@ struct ThreadClosureArg2 {
} // namespace base
} // namespace embb
#endif /* EMBB_BASE_INTERNAL_THREAD_CLOSURES_H_ */
#endif // EMBB_BASE_INTERNAL_THREAD_CLOSURES_H_
......@@ -149,4 +149,4 @@ void ThreadSpecificStorage<Type>::Prepare() {
} // namespace base
} // namespace embb
#endif /* EMBB_BASE_INTERNAL_THREAD_SPECIFIC_STORAGE_INL_H_ */
#endif // EMBB_BASE_INTERNAL_THREAD_SPECIFIC_STORAGE_INL_H_
......@@ -35,10 +35,10 @@ namespace embb {
namespace base {
namespace test {
/**
* Forward declaration for friending.
*/
class ThreadSpecificStorageTest;
/**
* Forward declaration for friending.
*/
class ThreadSpecificStorageTest;
}
/**
......@@ -176,4 +176,4 @@ class ThreadSpecificStorage {
#include <embb/base/internal/thread_specific_storage-inl.h>
#endif /* EMBB_BASE_THREAD_SPECIFIC_STORAGE_H_ */
#endif // EMBB_BASE_THREAD_SPECIFIC_STORAGE_H_
......@@ -78,4 +78,4 @@ class Time {
} // namespace base
} // namespace embb
#endif /* EMBB_BASE_TIME_H_ */
#endif // EMBB_BASE_TIME_H_
......@@ -42,7 +42,7 @@ class ThreadSpecificStorageTest : public partest::TestCase {
/**
* Adds test units.
*/
explicit ThreadSpecificStorageTest();
ThreadSpecificStorageTest();
private:
/**
......
......@@ -43,8 +43,7 @@ class ThreadTest : public partest::TestCase {
/**
* Adds test methods.
*/
explicit ThreadTest(); /**<
number of threads concurrently running test methods */
ThreadTest();
private:
/**
......
......@@ -87,9 +87,10 @@ class Inputs<Slices, T1, embb::base::internal::Nil, embb::base::internal::Nil,
}
virtual void OnClock(int clock) {
const int idx = clock % Slices;
if (count_[idx] == 0)
if (count_[idx] == 0) {
EMBB_THROW(embb::base::ErrorException,
"All inputs already fired for this clock.")
"All inputs already fired for this clock.");
}
if (--count_[idx] == 0) {
count_[idx] = 1;
listener_->OnClock(clock);
......@@ -132,9 +133,10 @@ class Inputs<Slices, T1, T2, embb::base::internal::Nil,
}
virtual void OnClock(int clock) {
const int idx = clock % Slices;
if (count_[idx] == 0)
if (count_[idx] == 0) {
EMBB_THROW(embb::base::ErrorException,
"All inputs already fired for this clock.")
"All inputs already fired for this clock.");
}
if (--count_[idx] == 0) {
count_[idx] = 2;
listener_->OnClock(clock);
......@@ -181,10 +183,11 @@ class Inputs<Slices, T1, T2, T3, embb::base::internal::Nil,
}
virtual void OnClock(int clock) {
const int idx = clock % Slices;
if (count_[idx] == 0)
if (count_[idx] == 0) {
EMBB_THROW(embb::base::ErrorException,
"All inputs already fired for this clock.")
if (--count_[idx] == 0) {
"All inputs already fired for this clock.");
}
if (--count_[idx] == 0) {
count_[idx] = 3;
listener_->OnClock(clock);
}
......@@ -233,9 +236,10 @@ class Inputs<Slices, T1, T2, T3, T4, embb::base::internal::Nil>
}
virtual void OnClock(int clock) {
const int idx = clock % Slices;
if (count_[idx] == 0)
if (count_[idx] == 0) {
EMBB_THROW(embb::base::ErrorException,
"All inputs already fired for this clock.")
"All inputs already fired for this clock.");
}
if (--count_[idx] == 0) {
count_[idx] = 4;
listener_->OnClock(clock);
......@@ -290,9 +294,10 @@ class Inputs
}
virtual void OnClock(int clock) {
const int idx = clock % Slices;
if (count_[idx] == 0)
if (count_[idx] == 0) {
EMBB_THROW(embb::base::ErrorException,
"All inputs already fired for this clock.")
"All inputs already fired for this clock.");
}
if (--count_[idx] == 0) {
count_[idx] = 5;
listener_->OnClock(clock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment