-
Notifications
You must be signed in to change notification settings - Fork 6k
[Cpp API Compatibility] Delete useless code and rename test files #78580
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
Changes from 1 commit
a45e7e0
7cee6e8
3dc2c05
53acaba
82768bc
a0be3de
88c0a55
90a73da
aaac6b3
d825db2
d6e9be4
ce84dbe
003897d
f8e3a74
85ae6b8
7c0fb0f
f9a4cb5
3d9f777
c661ed6
4447f88
ad97976
ac7bab4
283802c
253d526
89106a5
1fcc43d
ea0fa1f
52662f3
934b82a
d283912
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,28 +21,24 @@ | |
|
|
||
| #include "gtest/gtest.h" | ||
| #include "paddle/phi/backends/gpu/gpu_info.h" | ||
| #include "test/cpp/compat/cuda_test_utils.h" | ||
|
|
||
| // --------------------------------------------------------------------------- | ||
| // CUDAFunctions.h — covers the 2 missing lines: | ||
| // c10::cuda::device_synchronize() and c10::cuda::stream_synchronize() | ||
| // --------------------------------------------------------------------------- | ||
|
|
||
| TEST(CUDAFunctionsTest, DeviceSynchronize) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| // Exercises the PADDLE_ENFORCE_GPU_SUCCESS(cudaDeviceSynchronize()) branch | ||
| ASSERT_NO_THROW(c10::cuda::device_synchronize()); | ||
| } | ||
|
|
||
| TEST(CUDAFunctionsTest, StreamSynchronize) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| // Exercises phi::backends::gpu::GpuStreamSync() | ||
| auto stream = c10::cuda::getCurrentCUDAStream(); | ||
| ASSERT_NO_THROW(c10::cuda::stream_synchronize(stream)); | ||
| } | ||
|
|
||
| TEST(CUDAFunctionsTest, AtNamespaceAliases) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| // Exercises the using aliases in at::cuda namespace | ||
| ASSERT_NO_THROW(at::cuda::device_synchronize()); | ||
| auto stream = c10::cuda::getCurrentCUDAStream(); | ||
|
Comment on lines
31
to
53
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @youge325 话说这个当初为啥要加,现在又为啥要删?是因为只在 CUDA 上跑吗?其实我觉得如果可以的话,我还是希望这些单测能测就尽可能在 CPU 上测一测的,当初
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 当初用 Agent 加测试提高 coverage rate 的时候自动加的,按我的理解,如果能编译成功的话,那么测试也不能随便就 skip,所以现在就删了。 有些单测也确实可以在CPU上跑,条件编译一下测试用例就行,比如
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ShigureNyako 帮我看看
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 刚刚 auth 过期了,@ShigureNyako 看看呢!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ShigureNyako 请给我一个 GPU build 但运行时无可用 device/runtime 的例子,在 CI 当中并没有出现这种情况, GPU build 就是为了在有可用 device/runtime 的场景中运行,我原来的代码写错了所以现在删掉,你可能倒果为因了
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ShigureNyako 如果从严谨性上来看,确实会有编译期 当初早期 C++ 兼容性第一个 PR #74402 为赶 3.2 发版在拉分支前夕合入临时跳过了一些内容,应该是 defd6a3 跳过了一些新硬件(根据上一个 commit 99f7b88 的报错和该 commit message 看起来是 XPU 和 NPU,但日志已经过期看不到了)上的运行时问题,请着眼于该场景分析下具体可能存在的问题,以及是否有推荐的解决方案 注意,我们即便不能推广到所有硬件(比如 XPU 和 NPU),即便跳过部分硬件,也比直接放弃 CPU 测试更好,我们的目标不是一次修复所有硬件上的问题(当然可以更好),只是希望在确保 CPU 上能够有所监控 |
||
|
|
@@ -65,14 +61,12 @@ TEST(CUDAContextLightTest, IsAvailable) { | |
|
|
||
| // getNumGPUs() delegages to c10::cuda::device_count() | ||
| TEST(CUDAContextLightTest, GetNumGPUs) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| int64_t n = at::cuda::getNumGPUs(); | ||
| ASSERT_GE(n, 1); | ||
| } | ||
|
|
||
| // getCurrentDeviceProperties() / getDeviceProperties() | ||
| TEST(CUDAContextLightTest, DeviceProperties) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| cudaDeviceProp* prop = at::cuda::getCurrentDeviceProperties(); | ||
| ASSERT_NE(prop, nullptr); | ||
| // Sanity-check a few well-known fields | ||
|
|
@@ -87,15 +81,13 @@ TEST(CUDAContextLightTest, DeviceProperties) { | |
|
|
||
| // warp_size() | ||
| TEST(CUDAContextLightTest, WarpSize) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| int ws = at::cuda::warp_size(); | ||
| // All NVIDIA and AMD GPU architectures have warp size of 32 or 64 | ||
| ASSERT_TRUE(ws == 32 || ws == 64); | ||
| } | ||
|
|
||
| // canDeviceAccessPeer() — a device cannot peer-access itself | ||
| TEST(CUDAContextLightTest, CanDeviceAccessPeer) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| int device_id = phi::backends::gpu::GetCurrentDeviceId(); | ||
| // Self-to-self peer access is always false per CUDA spec | ||
| bool self_peer = at::cuda::canDeviceAccessPeer(device_id, device_id); | ||
|
|
@@ -104,26 +96,22 @@ TEST(CUDAContextLightTest, CanDeviceAccessPeer) { | |
|
|
||
| // Handle accessors — all must return non-null handles | ||
| TEST(CUDAContextLightTest, GetCurrentCUDABlasHandle) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| cublasHandle_t h = at::cuda::getCurrentCUDABlasHandle(); | ||
| ASSERT_NE(h, nullptr); | ||
| } | ||
|
|
||
| TEST(CUDAContextLightTest, GetCurrentCUDABlasLtHandle) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| cublasLtHandle_t h = at::cuda::getCurrentCUDABlasLtHandle(); | ||
| ASSERT_NE(h, nullptr); | ||
| } | ||
|
|
||
| TEST(CUDAContextLightTest, GetCurrentCUDASparseHandle) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| cusparseHandle_t h = at::cuda::getCurrentCUDASparseHandle(); | ||
| ASSERT_NE(h, nullptr); | ||
| } | ||
|
|
||
| #if defined(CUDART_VERSION) || defined(USE_ROCM) | ||
| TEST(CUDAContextLightTest, GetCurrentCUDASolverDnHandle) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| cusolverDnHandle_t h = at::cuda::getCurrentCUDASolverDnHandle(); | ||
| ASSERT_NE(h, nullptr); | ||
| } | ||
|
|
@@ -160,7 +148,6 @@ TEST(CUDAContextLightTest, GetChosenWorkspaceSize) { | |
|
|
||
| // getCUDABlasLtWorkspaceSize() / getCUDABlasLtWorkspace() | ||
| TEST(CUDAContextLightTest, CUDABlasLtWorkspace) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| size_t sz = at::cuda::getCUDABlasLtWorkspaceSize(); | ||
| ASSERT_GT(sz, 0UL); | ||
|
|
||
|
|
@@ -176,7 +163,6 @@ TEST(CUDAContextLightTest, CUDADeviceAllocatorSingleton) { | |
| } | ||
|
|
||
| TEST(CUDAContextLightTest, CUDADeviceAllocatorCloneAndCopyData) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| c10::Allocator* alloc = at::cuda::getCUDADeviceAllocator(); | ||
| ASSERT_NE(alloc, nullptr); | ||
|
|
||
|
|
@@ -207,7 +193,6 @@ TEST(CUDAContextLightTest, CUDADeviceAllocatorCloneAndCopyData) { | |
| } | ||
|
|
||
| TEST(CUDAContextLightTest, CUDADeviceAllocatorCloneZeroBytes) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| c10::Allocator* alloc = at::cuda::getCUDADeviceAllocator(); | ||
| ASSERT_NE(alloc, nullptr); | ||
|
|
||
|
|
@@ -220,7 +205,6 @@ TEST(CUDAContextLightTest, CUDADeviceAllocatorCloneZeroBytes) { | |
| } | ||
|
|
||
| TEST(CUDAContextLightTest, AllocatorZeroSizeAndNoopCopyBranches) { | ||
| SKIP_IF_CUDA_RUNTIME_UNAVAILABLE(); | ||
| c10::Allocator* alloc = at::cuda::getCUDADeviceAllocator(); | ||
| ASSERT_NE(alloc, nullptr); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.