SWDEV-470698 - fix formatting, add format check workflow (#657)
This commit is contained in:
committed by
GitHub
parent
5840940caa
commit
f7338717ae
@@ -15,7 +15,7 @@
|
||||
* LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test for checking order of execution of device kernel and
|
||||
@@ -33,8 +33,7 @@ constexpr auto threadsPerBlock = 256;
|
||||
static unsigned blocks = 0;
|
||||
|
||||
|
||||
template <typename T>
|
||||
class MemSetKernelTest {
|
||||
template <typename T> class MemSetKernelTest {
|
||||
public:
|
||||
T *A_h, *B_d, *B_h, *C_d;
|
||||
T memSetVal;
|
||||
@@ -49,28 +48,30 @@ class MemSetKernelTest {
|
||||
|
||||
A_h = reinterpret_cast<T*>(malloc(Nbytes));
|
||||
HIP_ASSERT(A_h != nullptr);
|
||||
HIP_CHECK(hipMalloc(&B_d , Nbytes));
|
||||
HIP_CHECK(hipMalloc(&B_d, Nbytes));
|
||||
B_h = reinterpret_cast<T*>(malloc(Nbytes));
|
||||
HIP_ASSERT(B_h != nullptr);
|
||||
HIP_CHECK(hipMalloc(&C_d , Nbytes));
|
||||
HIP_CHECK(hipMalloc(&C_d, Nbytes));
|
||||
|
||||
for (int i = 0 ; i < N ; i++) {
|
||||
for (int i = 0; i < N; i++) {
|
||||
B_h[i] = i;
|
||||
}
|
||||
HIP_CHECK(hipMemcpy(B_d , B_h , Nbytes , hipMemcpyHostToDevice));
|
||||
HIP_CHECK(hipMemcpy(B_d, B_h, Nbytes, hipMemcpyHostToDevice));
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
}
|
||||
|
||||
void memDeallocate() {
|
||||
HIP_CHECK(hipFree(B_d)); HIP_CHECK(hipFree(C_d));
|
||||
free(B_h); free(A_h);
|
||||
HIP_CHECK(hipFree(B_d));
|
||||
HIP_CHECK(hipFree(C_d));
|
||||
free(B_h);
|
||||
free(A_h);
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
void validateExecutionOrder() {
|
||||
for (int p = 0 ; p < N ; p++) {
|
||||
for (int p = 0; p < N; p++) {
|
||||
if (A_h[p] == memSetVal) {
|
||||
validateCount+= 1;
|
||||
validateCount += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,20 +88,18 @@ static bool testhipMemsetAsyncWithKernel(bool UseStrmPerThrd) {
|
||||
constexpr char memsetval = 0x42;
|
||||
|
||||
obj.memAllocate(memsetval);
|
||||
for (int k = 0 ; k < ITER ; ++k) {
|
||||
for (int k = 0; k < ITER; ++k) {
|
||||
if (UseStrmPerThrd) { // will use hipStreamPerThread stream object
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks),
|
||||
dim3(threadsPerBlock), 0, hipStreamPerThread, obj.B_d,
|
||||
obj.C_d, N);
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks), dim3(threadsPerBlock), 0,
|
||||
hipStreamPerThread, obj.B_d, obj.C_d, N);
|
||||
HIP_CHECK(hipGetLastError());
|
||||
HIP_CHECK(hipStreamSynchronize(hipStreamPerThread));
|
||||
HIP_CHECK(hipMemsetAsync(obj.C_d , obj.memSetVal, N, hipStreamPerThread));
|
||||
HIP_CHECK(hipMemsetAsync(obj.C_d, obj.memSetVal, N, hipStreamPerThread));
|
||||
HIP_CHECK(hipStreamSynchronize(hipStreamPerThread));
|
||||
} else {
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks),
|
||||
dim3(threadsPerBlock), 0, obj.stream, obj.B_d, obj.C_d,
|
||||
N);
|
||||
HIP_CHECK(hipMemsetAsync(obj.C_d , obj.memSetVal , N , obj.stream));
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks), dim3(threadsPerBlock), 0, obj.stream,
|
||||
obj.B_d, obj.C_d, N);
|
||||
HIP_CHECK(hipMemsetAsync(obj.C_d, obj.memSetVal, N, obj.stream));
|
||||
HIP_CHECK(hipStreamSynchronize(obj.stream));
|
||||
}
|
||||
HIP_CHECK(hipMemcpy(obj.A_h, obj.C_d, obj.Nbytes, hipMemcpyDeviceToHost));
|
||||
@@ -111,16 +110,15 @@ static bool testhipMemsetAsyncWithKernel(bool UseStrmPerThrd) {
|
||||
}
|
||||
|
||||
static bool testhipMemsetD32AsyncWithKernel() {
|
||||
MemSetKernelTest <int32_t> obj;
|
||||
MemSetKernelTest<int32_t> obj;
|
||||
constexpr int memsetD32val = 0xDEADBEEF;
|
||||
|
||||
obj.memAllocate(memsetD32val);
|
||||
for (int k = 0 ; k < ITER ; k++) {
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks),
|
||||
dim3(threadsPerBlock), 0, obj.stream, obj.B_d, obj.C_d, N);
|
||||
for (int k = 0; k < ITER; k++) {
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks), dim3(threadsPerBlock), 0, obj.stream,
|
||||
obj.B_d, obj.C_d, N);
|
||||
HIP_CHECK(hipGetLastError());
|
||||
HIP_CHECK(hipMemsetD32Async((hipDeviceptr_t)obj.C_d , obj.memSetVal,
|
||||
N, obj.stream));
|
||||
HIP_CHECK(hipMemsetD32Async((hipDeviceptr_t)obj.C_d, obj.memSetVal, N, obj.stream));
|
||||
HIP_CHECK(hipStreamSynchronize(obj.stream));
|
||||
HIP_CHECK(hipMemcpy(obj.A_h, obj.C_d, obj.Nbytes, hipMemcpyDeviceToHost));
|
||||
|
||||
@@ -130,16 +128,15 @@ static bool testhipMemsetD32AsyncWithKernel() {
|
||||
}
|
||||
|
||||
static bool testhipMemsetD16AsyncWithKernel() {
|
||||
MemSetKernelTest <int16_t> obj;
|
||||
MemSetKernelTest<int16_t> obj;
|
||||
constexpr int16_t memsetD16val = 0xDEAD;
|
||||
|
||||
obj.memAllocate(memsetD16val);
|
||||
for (int k = 0 ; k < ITER ; k++) {
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks),
|
||||
dim3(threadsPerBlock), 0, obj.stream, obj.B_d, obj.C_d, N);
|
||||
for (int k = 0; k < ITER; k++) {
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks), dim3(threadsPerBlock), 0, obj.stream,
|
||||
obj.B_d, obj.C_d, N);
|
||||
HIP_CHECK(hipGetLastError());
|
||||
HIP_CHECK(hipMemsetD16Async((hipDeviceptr_t)obj.C_d , obj.memSetVal,
|
||||
N, obj.stream));
|
||||
HIP_CHECK(hipMemsetD16Async((hipDeviceptr_t)obj.C_d, obj.memSetVal, N, obj.stream));
|
||||
HIP_CHECK(hipStreamSynchronize(obj.stream));
|
||||
HIP_CHECK(hipMemcpy(obj.A_h, obj.C_d, obj.Nbytes, hipMemcpyDeviceToHost));
|
||||
|
||||
@@ -149,16 +146,15 @@ static bool testhipMemsetD16AsyncWithKernel() {
|
||||
}
|
||||
|
||||
static bool testhipMemsetD8AsyncWithKernel() {
|
||||
MemSetKernelTest <char> obj;
|
||||
MemSetKernelTest<char> obj;
|
||||
constexpr char memsetD8val = 0xDE;
|
||||
|
||||
obj.memAllocate(memsetD8val);
|
||||
for (int k = 0; k < ITER; k++) {
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks),
|
||||
dim3(threadsPerBlock), 0, obj.stream, obj.B_d, obj.C_d, N);
|
||||
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks), dim3(threadsPerBlock), 0, obj.stream,
|
||||
obj.B_d, obj.C_d, N);
|
||||
HIP_CHECK(hipGetLastError());
|
||||
HIP_CHECK(hipMemsetD8Async((hipDeviceptr_t)obj.C_d, obj.memSetVal,
|
||||
N, obj.stream));
|
||||
HIP_CHECK(hipMemsetD8Async((hipDeviceptr_t)obj.C_d, obj.memSetVal, N, obj.stream));
|
||||
HIP_CHECK(hipStreamSynchronize(obj.stream));
|
||||
HIP_CHECK(hipMemcpy(obj.A_h, obj.C_d, obj.Nbytes, hipMemcpyDeviceToHost));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user