提交 6250d108 编写于 作者: L liaogang

FIX: clang-format

上级 ce70df86
...@@ -16,8 +16,8 @@ limitations under the License. */ ...@@ -16,8 +16,8 @@ limitations under the License. */
#include <stddef.h> // for size_t #include <stddef.h> // for size_t
#include <thrust/system_error.h>
#include <thrust/system/cuda/error.h> #include <thrust/system/cuda/error.h>
#include <thrust/system_error.h>
namespace paddle { namespace paddle {
namespace memory { namespace memory {
...@@ -36,14 +36,14 @@ inline void throw_on_error(cudaError_t e, const char* message) { ...@@ -36,14 +36,14 @@ inline void throw_on_error(cudaError_t e, const char* message) {
// default, we should use GPUAllocator<staging=false>. // default, we should use GPUAllocator<staging=false>.
template <bool staging> template <bool staging>
class GPUAllocator { class GPUAllocator {
public: public:
void* Alloc(size_t size); void* Alloc(size_t size);
void Free(void* p, size_t size); void Free(void* p, size_t size);
}; };
template <> template <>
class GPUAllocator<false> { class GPUAllocator<false> {
public: public:
void* Alloc(size_t size) { void* Alloc(size_t size) {
void* p = 0; void* p = 0;
cudaError_t result = cudaMalloc(&p, size); cudaError_t result = cudaMalloc(&p, size);
...@@ -60,22 +60,22 @@ public: ...@@ -60,22 +60,22 @@ public:
// that is returned if you ever call cudaFree after the // that is returned if you ever call cudaFree after the
// driver has already shutdown. This happens only if the // driver has already shutdown. This happens only if the
// process is terminating, in which case we don't care if // process is terminating, in which case we don't care if
// cudaFree succeeds. // cudaFree succeeds.
auto err = cudaFree(p); auto err = cudaFree(p);
if (err != cudaErrorCudartUnloading) { if (err != cudaErrorCudartUnloading) {
throw_on_error(err, "cudaFree failed"); throw_on_error(err, "cudaFree failed");
} }
} }
}; };
template <> template <>
class GPUAllocator<true> { class GPUAllocator<true> {
public: public:
void* Alloc(size_t size) { void* Alloc(size_t size) {
void* p = 0; void* p = 0;
cudaError_t result = cudaMallocHost(&p, size); cudaError_t result = cudaMallocHost(&p, size);
if (result == cudaSuccess) { if (result == cudaSuccess) {
return p; return p;
} }
// clear last error // clear last error
cudaGetLastError(); cudaGetLastError();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册