Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align memcpy buffers in viewcopy #228

Merged
merged 1 commit into from
May 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/viewcopy/viewcopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,23 +428,23 @@ inline constexpr auto is_AoSoA<llama::mapping::AoSoA<AD, RD, L>> = true;
auto main() -> int
try
{
const auto numThreads = static_cast<std::size_t>(omp_get_max_threads());
std::cout << "Threads: " << numThreads << "\n";

const auto dataSize
= std::reduce(arrayDims.begin(), arrayDims.end(), std::size_t{1}, std::multiplies{}) * llama::sizeOf<Particle>;
const auto numThreads = static_cast<std::size_t>(omp_get_max_threads());
std::cout << "Data size: " << dataSize << "\n";
std::cout << "Threads: " << numThreads << "\n";

std::ofstream plotFile{"viewcopy.tsv"};
plotFile.exceptions(std::ios::badbit | std::ios::failbit);
plotFile
<< "\"\"\t\"memcpy\"\t\"memcpy(p)\"\t\"memcpy\\\\\\_avx2\"\t\"memcpy\\\\\\_avx2(p)\"\t\"naive copy\"\t\"naive "
"copy(p)\"\t\"std::copy\"\t\"aosoa copy(r)\"\t\"aosoa copy(w)\"\t\"aosoa copy(r,p)\"\t\"aosoa copy(w,p)\"\n";

std::vector<std::byte> src(dataSize);
std::vector<std::byte, llama::bloballoc::AlignedAllocator<std::byte, 64>> src(dataSize);

auto benchmarkMemcpy = [&](std::string_view name, auto memcpy)
{
std::vector<std::byte> dst(dataSize);
std::vector<std::byte, llama::bloballoc::AlignedAllocator<std::byte, 64>> dst(dataSize);
Stopwatch watch;
for (auto i = 0; i < REPETITIONS; i++)
memcpy(dst.data(), src.data(), dataSize);
Expand Down