Optionally track max value seen during copy.
This commit is contained in:
parent
56a04592d5
commit
34fb0e4a8a
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#include <poly/memory.h>
|
#include <poly/memory.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#if !XE_LIKE_WIN32
|
#if !XE_LIKE_WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif // !XE_LIKE_WIN32
|
#endif // !XE_LIKE_WIN32
|
||||||
|
@ -34,45 +36,69 @@ size_t page_size() {
|
||||||
// http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/f2bc76cc65ffba51a141950f98e75364e49df874/entry/volk/kernels/volk/volk_32u_byteswap.h
|
// http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/f2bc76cc65ffba51a141950f98e75364e49df874/entry/volk/kernels/volk/volk_32u_byteswap.h
|
||||||
// http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/2c4c371885c31222362f70a1cd714415d1398021/entry/volk/kernels/volk/volk_64u_byteswap.h
|
// http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/2c4c371885c31222362f70a1cd714415d1398021/entry/volk/kernels/volk/volk_64u_byteswap.h
|
||||||
|
|
||||||
void copy_and_swap_16_aligned(uint16_t* dest, const uint16_t* src,
|
void copy_and_swap_16_aligned(uint16_t* dest, const uint16_t* src, size_t count,
|
||||||
size_t count) {
|
uint16_t* out_max_value) {
|
||||||
for (size_t i = 0; i < count; ++i) {
|
return copy_and_swap_16_unaligned(dest, src, count, out_max_value);
|
||||||
dest[i] = byte_swap(src[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_and_swap_16_unaligned(uint16_t* dest, const uint16_t* src,
|
void copy_and_swap_16_unaligned(uint16_t* dest, const uint16_t* src,
|
||||||
size_t count) {
|
size_t count, uint16_t* out_max_value) {
|
||||||
for (size_t i = 0; i < count; ++i) {
|
if (out_max_value) {
|
||||||
dest[i] = byte_swap(src[i]);
|
uint16_t max_value = 0;
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
uint16_t value = byte_swap(src[i]);
|
||||||
|
max_value = std::max(max_value, value);
|
||||||
|
dest[i] = value;
|
||||||
|
}
|
||||||
|
*out_max_value = max_value;
|
||||||
|
} else {
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
dest[i] = byte_swap(src[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_and_swap_32_aligned(uint32_t* dest, const uint32_t* src,
|
void copy_and_swap_32_aligned(uint32_t* dest, const uint32_t* src, size_t count,
|
||||||
size_t count) {
|
uint32_t* out_max_value) {
|
||||||
for (size_t i = 0; i < count; ++i) {
|
return copy_and_swap_32_unaligned(dest, src, count, out_max_value);
|
||||||
dest[i] = byte_swap(src[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_and_swap_32_unaligned(uint32_t* dest, const uint32_t* src,
|
void copy_and_swap_32_unaligned(uint32_t* dest, const uint32_t* src,
|
||||||
size_t count) {
|
size_t count, uint32_t* out_max_value) {
|
||||||
for (size_t i = 0; i < count; ++i) {
|
if (out_max_value) {
|
||||||
dest[i] = byte_swap(src[i]);
|
uint32_t max_value = 0;
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
uint32_t value = byte_swap(src[i]);
|
||||||
|
max_value = std::max(max_value, value);
|
||||||
|
dest[i] = value;
|
||||||
|
}
|
||||||
|
*out_max_value = max_value;
|
||||||
|
} else {
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
dest[i] = byte_swap(src[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_and_swap_64_aligned(uint64_t* dest, const uint64_t* src,
|
void copy_and_swap_64_aligned(uint64_t* dest, const uint64_t* src, size_t count,
|
||||||
size_t count) {
|
uint64_t* out_max_value) {
|
||||||
for (size_t i = 0; i < count; ++i) {
|
return copy_and_swap_64_unaligned(dest, src, count, out_max_value);
|
||||||
dest[i] = byte_swap(src[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_and_swap_64_unaligned(uint64_t* dest, const uint64_t* src,
|
void copy_and_swap_64_unaligned(uint64_t* dest, const uint64_t* src,
|
||||||
size_t count) {
|
size_t count, uint64_t* out_max_value) {
|
||||||
for (size_t i = 0; i < count; ++i) {
|
if (out_max_value) {
|
||||||
dest[i] = byte_swap(src[i]);
|
uint64_t max_value = 0;
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
uint64_t value = byte_swap(src[i]);
|
||||||
|
max_value = std::max(max_value, value);
|
||||||
|
dest[i] = value;
|
||||||
|
}
|
||||||
|
*out_max_value = max_value;
|
||||||
|
} else {
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
dest[i] = byte_swap(src[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,18 +29,21 @@ size_t hash_combine(size_t seed, const T& v, const Ts&... vs) {
|
||||||
|
|
||||||
size_t page_size();
|
size_t page_size();
|
||||||
|
|
||||||
void copy_and_swap_16_aligned(uint16_t* dest, const uint16_t* src,
|
void copy_and_swap_16_aligned(uint16_t* dest, const uint16_t* src, size_t count,
|
||||||
size_t count);
|
uint16_t* out_max_value = nullptr);
|
||||||
void copy_and_swap_16_unaligned(uint16_t* dest, const uint16_t* src,
|
void copy_and_swap_16_unaligned(uint16_t* dest, const uint16_t* src,
|
||||||
size_t count);
|
size_t count,
|
||||||
void copy_and_swap_32_aligned(uint32_t* dest, const uint32_t* src,
|
uint16_t* out_max_value = nullptr);
|
||||||
size_t count);
|
void copy_and_swap_32_aligned(uint32_t* dest, const uint32_t* src, size_t count,
|
||||||
|
uint32_t* out_max_value = nullptr);
|
||||||
void copy_and_swap_32_unaligned(uint32_t* dest, const uint32_t* src,
|
void copy_and_swap_32_unaligned(uint32_t* dest, const uint32_t* src,
|
||||||
size_t count);
|
size_t count,
|
||||||
void copy_and_swap_64_aligned(uint64_t* dest, const uint64_t* src,
|
uint32_t* out_max_value = nullptr);
|
||||||
size_t count);
|
void copy_and_swap_64_aligned(uint64_t* dest, const uint64_t* src, size_t count,
|
||||||
|
uint64_t* out_max_value = nullptr);
|
||||||
void copy_and_swap_64_unaligned(uint64_t* dest, const uint64_t* src,
|
void copy_and_swap_64_unaligned(uint64_t* dest, const uint64_t* src,
|
||||||
size_t count);
|
size_t count,
|
||||||
|
uint64_t* out_max_value = nullptr);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void copy_and_swap(T* dest, const T* src, size_t count) {
|
void copy_and_swap(T* dest, const T* src, size_t count) {
|
||||||
|
|
Loading…
Reference in New Issue