Skip to content

Commit

Permalink
Merge branch 'develop' into feature/precon-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
weinbe2 committed Aug 1, 2023
2 parents 62e5c3b + aedf545 commit 07466d1
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 14 deletions.
2 changes: 2 additions & 0 deletions include/communicator_quda.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,8 @@ namespace quda

void comm_allreduce_sum_array(double *data, size_t size);

void comm_allreduce_sum(size_t &a);

void comm_allreduce_max_array(double *data, size_t size);

void comm_allreduce_max_array(deviation_t<double> *data, size_t size);
Expand Down
10 changes: 5 additions & 5 deletions lib/color_spinor_util.in.cu
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace quda {
int compareSpinor(const U &u, const V &v, const int tol)
{
int fail_check = 16*tol;
std::vector<int> fail(fail_check);
std::vector<size_t> fail(fail_check);
for (int f=0; f<fail_check; f++) fail[f] = 0;

int N = 2*u.Nspin()*u.Ncolor();
Expand Down Expand Up @@ -224,9 +224,9 @@ namespace quda {

// reduce over all processes
for (int i=0; i<N; i++) comm_allreduce_int(iter[i]);
for (int f=0; f<fail_check; f++) comm_allreduce_int(fail[f]);
for (int f = 0; f < fail_check; f++) comm_allreduce_sum(fail[f]);

for (int i=0; i<N; i++) printfQuda("%d fails = %d\n", i, iter[i]);
for (int i = 0; i < N; i++) printfQuda("%d fails = %d\n", i, iter[i]);

int accuracy_level =0;
for (int f=0; f<fail_check; f++) {
Expand All @@ -235,8 +235,8 @@ namespace quda {

size_t total = u.Nparity()*u.VolumeCB()*N*comm_size();
for (int f=0; f<fail_check; f++) {
printfQuda("%e Failures: %d / %lu = %e\n", pow(10.0,-(f+1)/(double)tol),
fail[f], total, fail[f] / (double)total);
printfQuda("%e Failures: %lu / %lu = %e\n", pow(10.0, -(f + 1) / (double)tol), fail[f], total,
fail[f] / (double)total);
}

return accuracy_level;
Expand Down
10 changes: 10 additions & 0 deletions lib/communicator_mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ namespace quda
}
}

void Communicator::comm_allreduce_sum(size_t &a)
{
if (sizeof(size_t) != sizeof(unsigned long)) {
errorQuda("sizeof(size_t) != sizeof(unsigned long): %lu != %lu\n", sizeof(size_t), sizeof(unsigned long));
}
size_t recv;
MPI_CHECK(MPI_Allreduce(&a, &recv, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_HANDLE));
a = recv;
}

void Communicator::comm_allreduce_max_array(deviation_t<double> *data, size_t size)
{
size_t n = comm_size();
Expand Down
8 changes: 8 additions & 0 deletions lib/communicator_qmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,14 @@ void Communicator::comm_allreduce_sum_array(double *data, size_t size)
}
}

void Communicator::comm_allreduce_sum(size_t &a)
{
if (sizeof(size_t) != sizeof(uint64_t)) {
errorQuda("sizeof(size_t) != sizeof(uint64_t): %lu != %lu\n", sizeof(size_t), sizeof(uint64_t));
}
QMP_CHECK(QMP_comm_sum_uint64_t(QMP_COMM_HANDLE, reinterpret_cast<uint64_t *>(&a)));
}

void Communicator::comm_allreduce_max_array(deviation_t<double> *data, size_t size)
{
size_t n = comm_size();
Expand Down
2 changes: 2 additions & 0 deletions lib/communicator_single.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ namespace quda

void Communicator::comm_allreduce_sum_array(double *, size_t) { }

void Communicator::comm_allreduce_sum(size_t &) { }

void Communicator::comm_allreduce_max_array(deviation_t<double> *, size_t) { }

void Communicator::comm_allreduce_max_array(double *, size_t) { }
Expand Down
2 changes: 2 additions & 0 deletions lib/communicator_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ namespace quda

template <> void comm_allreduce_sum<double>(double &a) { comm_allreduce_sum_array(&a, 1); }

template <> void comm_allreduce_sum<size_t>(size_t &a) { get_current_communicator().comm_allreduce_sum(a); }

void comm_allreduce_max_array(double *data, size_t size)
{
get_current_communicator().comm_allreduce_max_array(data, size);
Expand Down
33 changes: 27 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -801,14 +801,24 @@ endif()

if(QUDA_DIRAC_STAGGERED)
set(DIRAC_NAME staggered)
add_test(NAME dslash_${DIRAC_NAME}_policy${pol2}
add_test(NAME dslash_${DIRAC_NAME}_matpc_policy${pol2}
COMMAND ${QUDA_CTEST_LAUNCH} $<TARGET_FILE:staggered_dslash_ctest> ${MPIEXEC_POSTFLAGS}
--dslash-type ${DIRAC_NAME}
--test MatPC
--dim 2 4 6 8
--gtest_output=xml:dslash_${DIRAC_NAME}_test_pol${pol2}.xml)
--gtest_output=xml:dslash_${DIRAC_NAME}_matpc_test_pol${pol2}.xml)
if(polenv)
set_tests_properties(dslash_${DIRAC_NAME}_policy${pol2} PROPERTIES ENVIRONMENT QUDA_ENABLE_DSLASH_POLICY=${pol2})
set_tests_properties(dslash_${DIRAC_NAME}_matpc_policy${pol2} PROPERTIES ENVIRONMENT QUDA_ENABLE_DSLASH_POLICY=${pol2})
endif()

add_test(NAME dslash_${DIRAC_NAME}_mat_policy${pol2}
COMMAND ${QUDA_CTEST_LAUNCH} $<TARGET_FILE:staggered_dslash_ctest> ${MPIEXEC_POSTFLAGS}
--dslash-type ${DIRAC_NAME}
--test Mat
--dim 2 4 6 8
--gtest_output=xml:dslash_${DIRAC_NAME}_mat_test_pol${pol2}.xml)
if(polenv)
set_tests_properties(dslash_${DIRAC_NAME}_mat_policy${pol2} PROPERTIES ENVIRONMENT QUDA_ENABLE_DSLASH_POLICY=${pol2})
endif()

add_test(NAME benchmark_dslash_${DIRAC_NAME}_policy${pol2}
Expand All @@ -824,15 +834,26 @@ endif()
endif()

set(DIRAC_NAME asqtad)
add_test(NAME dslash_${DIRAC_NAME}_policy${pol2}
add_test(NAME dslash_${DIRAC_NAME}_matpc_policy${pol2}
COMMAND ${QUDA_CTEST_LAUNCH} $<TARGET_FILE:staggered_dslash_ctest> ${MPIEXEC_POSTFLAGS}
--dslash-type ${DIRAC_NAME}
--all-partitions 1
--test MatPC
--dim 6 8 10 12
--gtest_output=xml:dslash_${DIRAC_NAME}_test_pol${pol2}.xml)
--gtest_output=xml:dslash_${DIRAC_NAME}_matpc_test_pol${pol2}.xml)
if(polenv)
set_tests_properties(dslash_${DIRAC_NAME}_matpc_policy${pol2} PROPERTIES ENVIRONMENT QUDA_ENABLE_DSLASH_POLICY=${pol2})
endif()

add_test(NAME dslash_${DIRAC_NAME}_mat_policy${pol2}
COMMAND ${QUDA_CTEST_LAUNCH} $<TARGET_FILE:staggered_dslash_ctest> ${MPIEXEC_POSTFLAGS}
--dslash-type ${DIRAC_NAME}
--all-partitions 1
--test Mat
--dim 6 8 10 12
--gtest_output=xml:dslash_${DIRAC_NAME}_mat_test_pol${pol2}.xml)
if(polenv)
set_tests_properties(dslash_${DIRAC_NAME}_policy${pol2} PROPERTIES ENVIRONMENT QUDA_ENABLE_DSLASH_POLICY=${pol2})
set_tests_properties(dslash_${DIRAC_NAME}_mat_policy${pol2} PROPERTIES ENVIRONMENT QUDA_ENABLE_DSLASH_POLICY=${pol2})
endif()

add_test(NAME benchmark_dslash_${DIRAC_NAME}_policy${pol2}
Expand Down
6 changes: 3 additions & 3 deletions tests/host_reference/staggered_dslash_reference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ void staggeredDslashReference(sFloat *res, gFloat **fatlink, gFloat **longlink,
sub(&res[offset], &res[offset], gaugedSpinor, stag_spinor_site_size);
}
}
} // forward/backward in all four directions

if (daggerBit) negx(&res[offset], stag_spinor_site_size);
} // 4-d volume
} // right-hand-side
if (daggerBit) negx(&res[offset], stag_spinor_site_size);
} // 4-d volume
}

void staggeredDslash(ColorSpinorField &out, void **fatlink, void **longlink, void **ghost_fatlink,
Expand Down

0 comments on commit 07466d1

Please sign in to comment.