@@ -410,43 +410,41 @@ struct CudaAllocator : private Arena {
410410
411411 T *allocate (size_t size) {
412412 void *ptr = nullptr ;
413- if (size >= std::numeric_limits<size_t >::max () / sizeof (T))
414- [[unlikely]] {
413+ if (sizeof (T) <= 1 || size > std::numeric_limits<size_t >::max () /
414+ sizeof (T)) [[unlikely]] {
415415 throw std::bad_array_new_length ();
416416 }
417417 cudaError_t res = Arena::doMalloc (&ptr, size * sizeof (T));
418- if (res != cudaSuccess ) [[unlikely]] {
418+ if (res == cudaErrorMemoryAllocation ) [[unlikely]] {
419419 throw std::bad_alloc ();
420420 }
421+ CHECK_CUDA ((" Arena::doMalloc" , res));
421422 return static_cast <T *>(ptr);
422423 }
423424
424- void deallocate (T *ptr, size_t size = 0 ) noexcept {
425- Arena::doFree (ptr);
425+ void deallocate (T *ptr, size_t size = 0 ) {
426+ CHECK_CUDA ( Arena::doFree (ptr) );
426427 }
427428
428429 template <class ... Args>
429430 static constexpr std::enable_if_t <sizeof ...(Args)>
430- construct (T *p, Args &&...args) noexcept (
431- noexcept ( ::new (p ) T(std::forward<Args>(args)...))) {
432- ::new (( void *)p ) T (std::forward<Args>(args)...);
431+ construct (T *p, Args &&...args) noexcept (noexcept (
432+ ::new (static_cast < void *>(p) ) T(std::forward<Args>(args)...))) {
433+ ::new (static_cast < void *>(p) ) T (std::forward<Args>(args)...);
433434 }
434435
435- static constexpr void construct (T *p) noexcept (noexcept (::new (p) T)) {
436- ::new ((void *)p) T;
436+ static constexpr void
437+ construct (T *p) noexcept (noexcept (::new (static_cast <void *>(p)) T)) {
438+ ::new (static_cast <void *>(p)) T;
437439 }
438440
439441 static constexpr void destroy (T *p) noexcept (noexcept (p->~T ())) {
440442 p->~T ();
441443 }
442444
443- template <class U > // cihou shabi wendous
445+ template <class U >
444446 constexpr CudaAllocator (CudaAllocator<U> const &other) noexcept {}
445447
446- constexpr bool operator ==(CudaAllocator<T> const &other) const noexcept {
447- return true ;
448- }
449-
450448 template <class U >
451449 constexpr bool operator ==(CudaAllocator<U> const &other) const noexcept {
452450 return true ;
0 commit comments