| 67 | */ |
| 68 | |
| 69 | TEST(MemPool, CompareCudaCnmem) { |
| 70 | singa::CudaMemPool cudaPool; |
| 71 | singa::CnMemPool cnPool; |
| 72 | |
| 73 | int numOfTests = 5000; |
| 74 | int allocSize = 32; |
| 75 | |
| 76 | singa::DeviceMemPool* pool = NULL; |
| 77 | pool = &cnPool; |
| 78 | |
| 79 | CUDA_CHECK(cudaSetDevice(0)); |
| 80 | singa::Timer tick; |
| 81 | for (int i = 0; i < numOfTests; i++) { |
| 82 | int* memPtrs = NULL; |
| 83 | pool->Malloc((void**)&memPtrs, allocSize); |
| 84 | pool->Free(memPtrs); |
| 85 | } |
| 86 | tick.Tick(); |
| 87 | int cn_time = tick.Elapsed(); |
| 88 | |
| 89 | pool = &cudaPool; |
| 90 | for (int i = 0; i < numOfTests; i++) { |
| 91 | int* memPtrs = NULL; |
| 92 | pool->Malloc((void**)&memPtrs, allocSize); |
| 93 | pool->Free(memPtrs); |
| 94 | } |
| 95 | tick.Tick(); |
| 96 | int cuda_time = tick.Elapsed(); |
| 97 | EXPECT_GE(cuda_time, cn_time); |
| 98 | } |
| 99 | #endif // USE_CUDA |