CTEST和MPI并行测试

发布于 2025-01-23 07:26:11 字数 854 浏览 2 评论 0原文

我正在尝试使用 googletest 应该测试某些MPI并行代码。理想情况下,我希望我们的CI服务器通过ctest执行它们。

我的天真方法是简单地使用mpi调用CTEST:

mpirun -n 3 ctest

但是,只要执行至少两个,这甚至导致琐碎的测试失败。

琐碎测试的示例:

TEST(TestSuite, DummyTest1) {
  EXPECT_TRUE(true);
}
TEST(TestSuite, DummyTest2) {
  EXPECT_TRUE(true);
}

我应该以其他方式启动ctest吗?还是我必须完全不同?

其他信息:

  • 测试是通过gtest_discover_tests()添加的。
  • 直接使用MPI(Mpirun -n 3 Testexe)启动测试可执行的测试成功测试,但我更喜欢使用ctest
  • 版本信息:
    • googletest:1.11.0
    • mpi:OpenMPI 4.0.3和mpich 3.3.2

I'm trying to build some tests with googleTest which should test some MPI parallel code. Ideally I want our CI server to execute them through ctest.

My naive approach was to simply call ctest with MPI:

mpirun -n 3 ctest

However, this results in even trivial tests failing as long as at least two are executed.

Example of a trivial tests:

TEST(TestSuite, DummyTest1) {
  EXPECT_TRUE(true);
}
TEST(TestSuite, DummyTest2) {
  EXPECT_TRUE(true);
}

Am I supposed to launch ctest in some other way? Or do I have to approach this completely differently?

Additional info:

  • The tests are added via gtest_discover_tests().
  • Launching the test executable directly with MPI (mpirun -n 3 testExe) yields successful tests but I would prefer using ctest.
  • Version info:
    • googletest: 1.11.0
    • MPI: OpenMPI 4.0.3 AND MPICH 3.3.2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神爱温柔 2025-01-30 07:26:11

根据 this cmake post,链接到CMAKE GITLAB存储库中的合并请求和问题,gtest_discover_tests()当前根本不支持MPI。

可能的解决方法是滥用crossCompiling_emulator属性,以将包装器注入测试命令。但是,这不仅改变了整个目标,而不仅会改变测试,因此您的里程可能会有所不同。

set_property(TARGET TheExe PROPERTY CROSSCOMPILING_EMULATOR '${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 3')
gtest_discover_tests(TheExe)

有关完整的示例,请参见论坛帖子。

According to this CMake Forum post, which links to a Merge Requests and an issue in the CMake GitLab repository, gtest_discover_tests() currently simply doesn't support MPI.

A possible workaround is to abuse the CROSSCOMPILING_EMULATOR property to inject the wrapper into the test command. However, this changes the whole target and not only the tests so your mileage may vary.

set_property(TARGET TheExe PROPERTY CROSSCOMPILING_EMULATOR '${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 3')
gtest_discover_tests(TheExe)

See the forum post for a full minimal example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文