Skip to content
Open
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
41844f2
Cit -m RAII guards for memory allocations and streams, define some co…
music-dino Sep 30, 2022
e4b1761
EXSWHTEC-74 - Implement tests for hipMemcpy and derivatives
music-dino Oct 3, 2022
1041227
EXSWHTEC-74 - Implement tests for hipMemcpy and derivatives
music-dino Oct 3, 2022
858da0e
Implement helper function for generating allocation flags
music-dino Oct 3, 2022
3a107b9
EXSWHTEC-74 - Remove hipMemcpyDtoD.cc
music-dino Oct 3, 2022
9023c00
Merge remote-tracking branch 'origin/utils' into hipMemcpy_tests
music-dino Oct 3, 2022
fbe7e2a
EXSWHTEC-74 - Add files as sources to Nvidia build
music-dino Oct 3, 2022
12a558c
EXSWHTEC-74 - Implement tests for hipMemcpyWithStream
music-dino Oct 3, 2022
e534d2e
EXSWHTEC-94 - Implement helper classes and functions for memory tests
music-dino Oct 6, 2022
ecc1092
Merge with branch origin/utils
music-dino Oct 6, 2022
3ac0227
Merge branch 'utils' into hipMemcpy_tests
music-dino Oct 6, 2022
09ce86a
EXSWHTEC-94 - Remove c++14 standard constraint on memory tests
music-dino Oct 6, 2022
c27d65b
Merge branch 'utils' into hipMemcpy_tests
music-dino Oct 6, 2022
48b337f
EXSWHTEC-94 - Remove GenerateLinearAllocationFlagCombinations until f…
music-dino Oct 6, 2022
2d3b7a7
Merge branch 'develop' into utils
music-dino Oct 8, 2022
2238061
Merge branch 'utils' into hipMemcpy_tests
music-dino Oct 10, 2022
1ce28d0
EXSWHTEC-74 - Implement allocation flag generating function and reorg…
music-dino Oct 10, 2022
654c3ab
Merge remote-tracking branch 'origin/hipMemcpy_tests' into hipMemcpy_…
music-dino Oct 10, 2022
783acf9
EXSWHTEC-74 - Implement p2p access for device to device tests, refact…
music-dino Oct 10, 2022
715cf30
EXSWHTEC-94 - Implement helper classes and functions for memory tests
music-dino Oct 6, 2022
a74fe21
EXSWHTEC-94 - Remove c++14 standard constraint on memory tests
music-dino Oct 6, 2022
350958e
EXSWHTEC-94 - Remove GenerateLinearAllocationFlagCombinations until f…
music-dino Oct 6, 2022
ea6689c
Merge branch 'develop' into utils
music-dino Oct 10, 2022
2a44046
Merge remote-tracking branch 'origin/utils' into utils
mirza-halilcevic Oct 10, 2022
691d00e
EXSWHTEC-94 - Implement helper classes and functions for memory tests
music-dino Oct 6, 2022
7bdf52f
EXSWHTEC-94 - Remove c++14 standard constraint on memory tests
music-dino Oct 6, 2022
1185c39
EXSWHTEC-94 - Remove GenerateLinearAllocationFlagCombinations until f…
music-dino Oct 6, 2022
8d2e833
Merge remote-tracking branch 'origin/utils' into utils
music-dino Oct 11, 2022
aadff52
Merge remote-tracking branch 'upstream/develop' into hipMemcpy_tests
music-dino Oct 12, 2022
68613db
EXSWHTEC-74 - Correct allocation types for host to device and device …
music-dino Oct 12, 2022
e003c4f
Merge remote-tracking branch 'origin/utils' into utils
mirza-halilcevic Oct 12, 2022
8911eb7
EXSWHTEC-94 - Implement resource guards for hipMallocPitch and 3D
mirza-halilcevic Oct 12, 2022
e31a753
EXSWHTEC-74 - Rectify compilation warnings
music-dino Oct 12, 2022
e13544e
EXSWHTEC-74 - Fix expected error codes in MemcpyWithStream negative t…
music-dino Oct 12, 2022
d0ac81e
EXSWHTEC-74 - Update basic positive test for host to device copies
music-dino Oct 14, 2022
78a943d
EXSWHTEC-74 - Update test names for hipMemcpyWithStream and hipMemcpy…
music-dino Oct 14, 2022
b1a68bd
Merge remote-tracking branch 'origin/utils' into utils
music-dino Oct 14, 2022
76c8e31
EXSWHTEC-94 - Add resource guards for 2D and 3D allocations and utils…
music-dino Oct 14, 2022
35f373e
Merge remote-tracking branch 'upstream/develop' into utils
music-dino Oct 14, 2022
10aa914
Merge branch 'utils' into hipMemcpy_tests
music-dino Oct 17, 2022
f04c3d2
EXSWHTEC-74 - Fix license boilerplate
music-dino Oct 17, 2022
7734178
EXSWHTEC-94 - Implement resource guards for arrays.
mirza-halilcevic Oct 18, 2022
25679d8
Merge remote-tracking branch 'upstream/develop' into utils
mirza-halilcevic Oct 18, 2022
1fd1cb0
EXSWHTEC-94 - Add hip_array_common.hh.
mirza-halilcevic Oct 18, 2022
fc3a107
EXSWHTEC-94 - Remove redundancies between hip_array_common.hh and
mirza-halilcevic Oct 18, 2022
0f82c25
Merge remote-tracking branch 'upstream/develop' into hipMemcpy_tests
music-dino Nov 2, 2022
bf3224f
EXSWHTEC-74 - Resolve control reaches end of non void function warnin…
music-dino Nov 2, 2022
dfdc1ba
Merge branch 'develop' into hipMemcpy_tests
music-dino Nov 3, 2022
995d5c3
Merge remote-tracking branch 'upstream/develop' into utils
music-dino Nov 4, 2022
4e2fe8d
EXSWHTEC-94 - Fix loop counter types in PitchedMemoryVerify and Pitch…
music-dino Nov 4, 2022
7e41f7c
Merge remote-tracking branch 'origin/utils' into hipMemcpy_tests
music-dino Nov 4, 2022
329a0ed
Merge remote-tracking branch 'origin/hipMemcpy_tests' into hipMemcpy_…
music-dino Nov 4, 2022
6ba63ea
EXSWHTEC-74 - Disable test sections that fail due to defects
music-dino Nov 4, 2022
1642475
Merge branch 'develop' into hipMemcpy_tests
mangupta Nov 14, 2022
fbd0c09
Merge branch 'develop' into hipMemcpy_tests
gargrahul Dec 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 61 additions & 4 deletions tests/catch/include/resource_guards.hh
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,74 @@ template <typename T> class LinearAllocGuard {
}
}

T* ptr() { return ptr_; };
T* const ptr() const { return ptr_; };
T* host_ptr() { return host_ptr_; }
T* const host_ptr() const { return host_ptr(); }
T* ptr() const { return ptr_; };
T* host_ptr() const { return host_ptr_; }

private:
const LinearAllocs allocation_type_;
T* ptr_ = nullptr;
T* host_ptr_ = nullptr;
};

template <typename T> class LinearAllocGuardMultiDim {
protected:
LinearAllocGuardMultiDim(hipExtent extent)
: extent_{extent} {}

~LinearAllocGuardMultiDim() {
static_cast<void>(hipFree(pitched_ptr_.ptr));
}

public:
T* ptr() const { return reinterpret_cast<T*>(pitched_ptr_.ptr); };

size_t pitch() const { return pitched_ptr_.pitch; }

hipExtent extent() const { return extent_; }

hipPitchedPtr pitched_ptr() const { return pitched_ptr_; }

size_t width() const { return extent_.width; }

size_t width_logical() const { return extent_.width / sizeof(T); }

size_t height() const { return extent_.height; }

public:
hipPitchedPtr pitched_ptr_;
const hipExtent extent_;
};

template <typename T> class LinearAllocGuard2D : public LinearAllocGuardMultiDim<T> {
public:
LinearAllocGuard2D(const size_t width_logical, const size_t height)
: LinearAllocGuardMultiDim<T>{make_hipExtent(width_logical * sizeof(T), height, 1)}
{
HIP_CHECK(hipMallocPitch(&this->pitched_ptr_.ptr, &this->pitched_ptr_.pitch, this->extent_.width, this->extent_.height));
}

LinearAllocGuard2D(const LinearAllocGuard2D&) = delete;
LinearAllocGuard2D(LinearAllocGuard2D&&) = delete;
};

template <typename T> class LinearAllocGuard3D : public LinearAllocGuardMultiDim<T> {
public:
LinearAllocGuard3D(const size_t width_logical, const size_t height, const size_t depth)
: LinearAllocGuardMultiDim<T>{make_hipExtent(width_logical * sizeof(T), height, depth)}
{
HIP_CHECK(hipMalloc3D(&this->pitched_ptr_, this->extent_));
}

LinearAllocGuard3D(const hipExtent extent) : LinearAllocGuardMultiDim<T>(extent) {
HIP_CHECK(hipMalloc3D(&this->pitched_ptr_, this->extent_));
}

LinearAllocGuard3D(const LinearAllocGuard3D&) = delete;
LinearAllocGuard3D(LinearAllocGuard3D&&) = delete;

size_t depth() const { return this->extent_.depth; }
};

enum class Streams { nullstream, perThread, created };

class StreamGuard {
Expand Down
43 changes: 43 additions & 0 deletions tests/catch/include/utils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,37 @@ void ArrayFindIfNot(T* const array, const T expected_value, const size_t num_ele
ArrayFindIfNot(array, array + num_elements, expected_value);
}

template <typename T, typename F>
void PitchedMemoryVerify(T* const ptr, const size_t pitch, const size_t width, const size_t height,
const size_t depth, F expected_value_generator) {
for (int z = 0; z < depth; ++z) {
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
const auto slice = reinterpret_cast<uint8_t*>(ptr) + pitch * height * z;
const auto row = slice + pitch * y;
if (reinterpret_cast<T*>(row)[x] != expected_value_generator(x, y, z)) {
INFO("Mismatch at indices: " << x << ", " << y << ", " << z);
REQUIRE(reinterpret_cast<T*>(row)[x] == expected_value_generator(x, y, z));
}
}
}
}
}

template <typename T, typename F>
void PitchedMemorySet(T* const ptr, const size_t pitch, const size_t width, const size_t height,
const size_t depth, F expected_value_generator) {
for (int z = 0; z < depth; ++z) {
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
const auto slice = reinterpret_cast<uint8_t*>(ptr) + pitch * height * z;
const auto row = slice + pitch * y;
reinterpret_cast<T*>(row)[x] = expected_value_generator(x, y, z);
}
}
}
}

template <typename T>
__global__ void VectorIncrement(T* const vec, const T increment_value, size_t N) {
size_t offset = (blockIdx.x * blockDim.x + threadIdx.x);
Expand Down Expand Up @@ -82,6 +113,18 @@ static __global__ void Delay(uint32_t interval, const uint32_t ticks_per_ms) {
}
}

template <typename T>
__global__ void Iota(T* const out, size_t pitch, size_t w, size_t h, size_t d) {
const auto x = blockIdx.x * blockDim.x + threadIdx.x;
const auto y = blockIdx.y * blockDim.y + threadIdx.y;
const auto z = blockIdx.z * blockDim.z + threadIdx.z;
if (x < w && y < h && z < d) {
char* const slice = reinterpret_cast<char*>(out) + pitch * h * z;
char* const row = slice + pitch * y;
reinterpret_cast<T*>(row)[x] = z * w * h + y * w + x;
}
}

inline void LaunchDelayKernel(const std::chrono::milliseconds interval, const hipStream_t stream) {
int ticks_per_ms = 0;
// Clock rate is in kHz => number of clock ticks in a millisecond
Expand Down
10 changes: 8 additions & 2 deletions tests/catch/unit/memory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,18 @@ set(TEST_SRC
hipMemcpyPeer.cc
hipMemcpyPeerAsync.cc
hipMemcpyWithStream.cc
hipMemcpyWithStream_old.cc
hipMemcpyWithStreamMultiThread.cc
hipMemsetAsyncAndKernel.cc
hipMemset2DAsyncMultiThreadAndKernel.cc
hipMallocManaged.cc
hipMallocConcurrency.cc
hipMemcpyDtoD.cc
hipMemcpyDtoD_old.cc
hipMemcpyDtoDAsync.cc
hipHostMalloc.cc
hipMemcpy.cc
hipMemcpy_derivatives.cc
hipMemcpy_old.cc
hipMemcpyAsync.cc
hipMemsetFunctional.cc
hipMallocPitch.cc
Expand Down Expand Up @@ -142,15 +145,18 @@ set(TEST_SRC
hipMemcpyPeer.cc
hipMemcpyPeerAsync.cc
hipMemcpyWithStream.cc
hipMemcpyWithStream_old.cc
hipMemcpyWithStreamMultiThread.cc
hipMemsetAsyncAndKernel.cc
hipMemset2DAsyncMultiThreadAndKernel.cc
hipMallocManaged.cc
hipMallocConcurrency.cc
hipMemcpyDtoD.cc
hipMemcpyDtoD_old.cc
hipMemcpyDtoDAsync.cc
hipHostMalloc.cc
hipMemcpy.cc
hipMemcpy_derivatives.cc
hipMemcpy_old.cc
hipMemcpyAsync.cc
hipMemsetFunctional.cc
hipMallocPitch.cc
Expand Down
Loading