‘’'cpp
include <cuda_runtime.h>
include <gtest/gtest.h>
TEST(CUDA_RUNTIME_TEST, MemPoolSupport){
int driverVersion = 0;
int deviceSupportsMemoryPools = 0;
int poolSupportedHandleTypes = 0;
cudaDriverGetVersion(&driverVersion);
if (driverVersion >= 11020) {
cudaDeviceGetAttribute(&deviceSupportsMemoryPools, cudaDevAttrMemoryPoolsSupported, 0);
}
if (deviceSupportsMemoryPools != 0) {
GTEST_LOG_(INFO) << " device
supports the Stream Ordered Memory Allocator";
}
if (driverVersion >= 11030) {
cudaDeviceGetAttribute(&poolSupportedHandleTypes, cudaDevAttrMemoryPoolSupportedHandleTypes, 0);
}
GTEST_LOG_(INFO) << "poolSupportedHandleTypes: " << poolSupportedHandleTypes;
if (poolSupportedHandleTypes & cudaMemHandleTypePosixFileDescriptor) {
GTEST_LOG_(INFO) << "Pools on the specified device can be created with posix file descriptor-based IPC";
}
cudaMemPool_t pool;
cudaMemPoolProps pool_props{};
pool_props.allocType = cudaMemAllocationTypePinned;
pool_props.handleTypes = cudaMemHandleTypeNone;
pool_props.location.type = ::cudaMemLocationTypeDevice;
pool_props.location.id = 0;
auto err = cudaMemPoolCreate(&pool, &pool_props);
EXPECT_EQ(err, cudaSuccess) << "create mem pool error: " << cudaGetErrorString(err);
}
‘’’
‘invalid argument’ returned at invoking ‘cudaMemPoolCreate’