Skip to content

Commit a913bdb

Browse files
committed
use std::size_t instead of size_t
1 parent 8aac0cf commit a913bdb

15 files changed

+222
-210
lines changed

include/DeviceAPICalls.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace dftfe
1313
deviceReset();
1414

1515
deviceError_t
16-
deviceMemGetInfo(size_t *free, size_t *total);
16+
deviceMemGetInfo(std::size_t *free, std::size_t *total);
1717

1818
deviceError_t
1919
getDeviceCount(int *count);
@@ -25,10 +25,10 @@ namespace dftfe
2525
setDevice(int deviceId);
2626

2727
deviceError_t
28-
deviceMalloc(void **devPtr, size_t size);
28+
deviceMalloc(void **devPtr, std::size_t size);
2929

3030
deviceError_t
31-
deviceMemset(void *devPtr, int value, size_t count);
31+
deviceMemset(void *devPtr, int value, std::size_t count);
3232

3333
/**
3434
* @brief
@@ -38,13 +38,13 @@ namespace dftfe
3838
*/
3939
template <typename ValueType>
4040
void
41-
deviceSetValue(ValueType *devPtr, ValueType value, size_t size);
41+
deviceSetValue(ValueType *devPtr, ValueType value, std::size_t size);
4242

4343
deviceError_t
4444
deviceFree(void *devPtr);
4545

4646
deviceError_t
47-
deviceHostMalloc(void **hostPtr, size_t size);
47+
deviceHostMalloc(void **hostPtr, std::size_t size);
4848

4949
deviceError_t
5050
deviceHostFree(void *hostPtr);
@@ -54,57 +54,57 @@ namespace dftfe
5454
* @param count The memory size in bytes of the array
5555
*/
5656
deviceError_t
57-
deviceMemcpyD2H(void *dst, const void *src, size_t count);
57+
deviceMemcpyD2H(void *dst, const void *src, std::size_t count);
5858

5959
/**
6060
* @brief Copy array from device to device
6161
* @param count The memory size in bytes of the array
6262
*/
6363
deviceError_t
64-
deviceMemcpyD2D(void *dst, const void *src, size_t count);
64+
deviceMemcpyD2D(void *dst, const void *src, std::size_t count);
6565

6666
/**
6767
* @brief Copy array from host to device
6868
* @param count The memory size in bytes of the array
6969
*/
7070
deviceError_t
71-
deviceMemcpyH2D(void *dst, const void *src, size_t count);
71+
deviceMemcpyH2D(void *dst, const void *src, std::size_t count);
7272

7373
/**
7474
* @brief Copy 2D array from device to host
7575
* @param count The memory size in bytes of the array
7676
*/
7777
deviceError_t
7878
deviceMemcpyD2H_2D(void * dst,
79-
size_t dpitch,
79+
std::size_t dpitch,
8080
const void *src,
81-
size_t spitch,
82-
size_t width,
83-
size_t height);
81+
std::size_t spitch,
82+
std::size_t width,
83+
std::size_t height);
8484

8585
/**
8686
* @brief Copy 2D array from device to device
8787
* @param count The memory size in bytes of the array
8888
*/
8989
deviceError_t
9090
deviceMemcpyD2D_2D(void * dst,
91-
size_t dpitch,
91+
std::size_t dpitch,
9292
const void *src,
93-
size_t spitch,
94-
size_t width,
95-
size_t height);
93+
std::size_t spitch,
94+
std::size_t width,
95+
std::size_t height);
9696

9797
/**
9898
* @brief Copy 2D array from host to device
9999
* @param count The memory size in bytes of the array
100100
*/
101101
deviceError_t
102102
deviceMemcpyH2D_2D(void * dst,
103-
size_t dpitch,
103+
std::size_t dpitch,
104104
const void *src,
105-
size_t spitch,
106-
size_t width,
107-
size_t height);
105+
std::size_t spitch,
106+
std::size_t width,
107+
std::size_t height);
108108

109109
/**
110110
* @brief HOST-DEVICE synchronization
@@ -119,7 +119,7 @@ namespace dftfe
119119
deviceError_t
120120
deviceMemcpyAsyncD2H(void * dst,
121121
const void * src,
122-
size_t count,
122+
std::size_t count,
123123
deviceStream_t stream = 0);
124124

125125
/**
@@ -129,7 +129,7 @@ namespace dftfe
129129
deviceError_t
130130
deviceMemcpyAsyncD2D(void * dst,
131131
const void * src,
132-
size_t count,
132+
std::size_t count,
133133
deviceStream_t stream = 0);
134134

135135
/**
@@ -139,7 +139,7 @@ namespace dftfe
139139
deviceError_t
140140
deviceMemcpyAsyncH2D(void * dst,
141141
const void * src,
142-
size_t count,
142+
std::size_t count,
143143
deviceStream_t stream = 0);
144144

145145

include/MemoryManager.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <TypeConfig.h>
55
#include <MemorySpaceType.h>
6+
#include <vector>
67

78
namespace dftfe
89
{
@@ -16,27 +17,27 @@ namespace dftfe
1617
{
1718
public:
1819
static void
19-
allocate(size_t size, ValueType **ptr);
20+
allocate(std::size_t size, ValueType **ptr);
2021

2122
static void
2223
deallocate(ValueType *ptr);
2324

2425
static void
25-
set(size_t size, ValueType *ptr, ValueType val);
26+
set(std::size_t size, ValueType *ptr, ValueType val);
2627
};
2728

2829
template <typename ValueType>
2930
class MemoryManager<ValueType, MemorySpace::HOST>
3031
{
3132
public:
3233
static void
33-
allocate(size_t size, ValueType **ptr);
34+
allocate(std::size_t size, ValueType **ptr);
3435

3536
static void
3637
deallocate(ValueType *ptr);
3738

3839
static void
39-
set(size_t size, ValueType *ptr, ValueType val);
40+
set(std::size_t size, ValueType *ptr, ValueType val);
4041
};
4142

4243
#ifdef DFTFE_WITH_DEVICE
@@ -45,13 +46,13 @@ namespace dftfe
4546
{
4647
public:
4748
static void
48-
allocate(size_t size, ValueType **ptr);
49+
allocate(std::size_t size, ValueType **ptr);
4950

5051
static void
5152
deallocate(ValueType *ptr);
5253

5354
static void
54-
set(size_t size, ValueType *ptr, ValueType val);
55+
set(std::size_t size, ValueType *ptr, ValueType val);
5556
};
5657

5758

@@ -60,13 +61,13 @@ namespace dftfe
6061
{
6162
public:
6263
static void
63-
allocate(size_t size, ValueType **ptr);
64+
allocate(std::size_t size, ValueType **ptr);
6465

6566
static void
6667
deallocate(ValueType *ptr);
6768

6869
static void
69-
set(size_t size, ValueType *ptr, ValueType val);
70+
set(std::size_t size, ValueType *ptr, ValueType val);
7071
};
7172
#endif // DFTFE_WITH_DEVICE
7273
} // namespace utils

include/MemoryStorage.h

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace dftfe
7474
* @param[in] size size of the Vector
7575
* @param[in] initVal initial value of elements of the Vector
7676
*/
77-
explicit MemoryStorage(size_t size, ValueType initVal = 0);
77+
explicit MemoryStorage(std::size_t size, ValueType initVal = 0);
7878

7979
/**
8080
* @brief Destructor
@@ -155,15 +155,15 @@ namespace dftfe
155155
* @returns reference to the element of the Vector
156156
* @throws exception if i >= size of the Vector
157157
*/
158-
reference operator[](size_t i);
158+
reference operator[](std::size_t i);
159159

160160
/**
161161
* @brief Operator to get a const reference to a element of the Vector
162162
* @param[in] i is the index to the element of the Vector
163163
* @returns const reference to the element of the Vector
164164
* @throws exception if i >= size of the Vector
165165
*/
166-
const_reference operator[](size_t i) const;
166+
const_reference operator[](std::size_t i) const;
167167

168168
void
169169
swap(MemoryStorage &rhs);
@@ -175,13 +175,13 @@ namespace dftfe
175175
* @param[in] initVal initial value of elements of the Vector
176176
*/
177177
void
178-
resize(size_t size, ValueType initVal = ValueType());
178+
resize(std::size_t size, ValueType initVal = ValueType());
179179

180180
/**
181181
* @brief Returns the dimension of the Vector
182182
* @returns size of the Vector
183183
*/
184-
size_t
184+
std::size_t
185185
size() const;
186186

187187
/**
@@ -246,9 +246,9 @@ namespace dftfe
246246
template <dftfe::utils::MemorySpace memorySpaceDst>
247247
void
248248
copyTo(MemoryStorage<ValueType, memorySpaceDst> &dstMemoryStorage,
249-
const size_t N,
250-
const size_t srcOffset,
251-
const size_t dstOffset) const;
249+
const std::size_t N,
250+
const std::size_t srcOffset,
251+
const std::size_t dstOffset) const;
252252

253253
/**
254254
* @brief Copies data from a MemoryStorage object in a different memory space.
@@ -297,9 +297,9 @@ namespace dftfe
297297
template <dftfe::utils::MemorySpace memorySpaceSrc>
298298
void
299299
copyFrom(MemoryStorage<ValueType, memorySpaceSrc> &srcMemoryStorage,
300-
const size_t N,
301-
const size_t srcOffset,
302-
const size_t dstOffset);
300+
const std::size_t N,
301+
const std::size_t srcOffset,
302+
const std::size_t dstOffset);
303303

304304
/**
305305
* @brief Copies the data to a memory pointed by a raw pointer
@@ -344,10 +344,10 @@ namespace dftfe
344344
*/
345345
template <dftfe::utils::MemorySpace memorySpaceDst>
346346
void
347-
copyTo(ValueType * dst,
348-
const size_t N,
349-
const size_t srcOffset,
350-
const size_t dstOffset) const;
347+
copyTo(ValueType * dst,
348+
const std::size_t N,
349+
const std::size_t srcOffset,
350+
const std::size_t dstOffset) const;
351351

352352
/**
353353
* @brief Copies data from a memory pointed by a raw pointer into
@@ -391,10 +391,10 @@ namespace dftfe
391391
*/
392392
template <dftfe::utils::MemorySpace memorySpaceSrc>
393393
void
394-
copyFrom(const ValueType *src,
395-
const size_t N,
396-
const size_t srcOffset,
397-
const size_t dstOffset);
394+
copyFrom(const ValueType * src,
395+
const std::size_t N,
396+
const std::size_t srcOffset,
397+
const std::size_t dstOffset);
398398

399399
/**
400400
* @brief Copies the data to a C++ STL vector, which always resides in
@@ -445,9 +445,9 @@ namespace dftfe
445445
*/
446446
void
447447
copyTo(std::vector<ValueType> &dst,
448-
const size_t N,
449-
const size_t srcOffset,
450-
const size_t dstOffset) const;
448+
const std::size_t N,
449+
const std::size_t srcOffset,
450+
const std::size_t dstOffset) const;
451451

452452
/**
453453
* @brief Copies data from a C++ STL vector to the MemoryStorage object,
@@ -489,14 +489,14 @@ namespace dftfe
489489
*/
490490
void
491491
copyFrom(const std::vector<ValueType> &src,
492-
const size_t N,
493-
const size_t srcOffset,
494-
const size_t dstOffset);
492+
const std::size_t N,
493+
const std::size_t srcOffset,
494+
const std::size_t dstOffset);
495495

496496

497497
private:
498-
ValueType *d_data = nullptr;
499-
size_t d_size = 0;
498+
ValueType * d_data = nullptr;
499+
std::size_t d_size = 0;
500500
};
501501

502502
//

0 commit comments

Comments
 (0)