diff --git a/c10/cuda/CUDACachingAllocator.cpp b/c10/cuda/CUDACachingAllocator.cpp index be6ca40a7b0..88a40f8c051 100644 --- a/c10/cuda/CUDACachingAllocator.cpp +++ b/c10/cuda/CUDACachingAllocator.cpp @@ -1080,19 +1080,12 @@ class RingBuffer { void getEntries(std::vector& result) const { std::lock_guard lk(alloc_trace_lock); - result.reserve(alloc_trace->size()); - result.insert( - result.end(), - alloc_trace->begin() + - static_cast::difference_type>( - alloc_trace_next), - alloc_trace->end()); - result.insert( - result.end(), + result.reserve(result.size() + alloc_trace->size()); + std::rotate_copy( alloc_trace->begin(), - alloc_trace->begin() + - static_cast::difference_type>( - alloc_trace_next)); + std::next(alloc_trace->begin(), alloc_trace_next), + alloc_trace->end(), + std::back_inserter(result)); } void clear() { @@ -4466,10 +4459,7 @@ struct BackendStaticInitializer { if (kv[0] == "backend") { #ifdef USE_ROCM // convenience for ROCm users to allow either CUDA or HIP env var - if (kv[1] == - "cud" - "aMallocAsync" || - kv[1] == "hipMallocAsync") + if (kv[1] == "cudaMallocAsync" || kv[1] == "hipMallocAsync") #else if (kv[1] == "cudaMallocAsync") #endif @@ -4491,9 +4481,7 @@ struct BackendStaticInitializer { // HIPAllocatorMasqueradingAsCUDA because it needs to happen during static // initialization, and doing so there may introduce static initialization // order (SIOF) issues. -#define HIP_MASQUERADING_AS_CUDA \ - "cud" \ - "a" +#define HIP_MASQUERADING_AS_CUDA "cuda" at::SetAllocator(c10::Device(HIP_MASQUERADING_AS_CUDA).type(), r, 0); allocator.store(r); #undef HIP_MASQUERADING_AS_CUDA