Skip to content

Commit

Permalink
[aligned-types-] replace uint4_aligned_2 with uint8_aligned; add the …
Browse files Browse the repository at this point in the history
…tests of uint8 aligned/misaligned types
  • Loading branch information
Jin Z committed Apr 18, 2023
1 parent a9102f1 commit 299d235
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
14 changes: 11 additions & 3 deletions aligned-types-cuda/main.cu
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ typedef struct
unsigned int r, g, b, a;
} uint4_misaligned;

typedef struct
{
uint4_misaligned c1, c2;
}
uint8_misaligned;


////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -97,7 +102,7 @@ typedef struct __align__(16)
{
uint4_aligned c1, c2;
}
uint4_aligned_2;
uint8_aligned;



Expand Down Expand Up @@ -303,8 +308,11 @@ int main(int argc, char **argv)
printf("uint4_aligned...\n");
nTotalFailures += runTest<uint4_aligned>(d_idata, d_odata, 16, MemorySize);

printf("uint4_aligned_2...\n");
nTotalFailures += runTest<uint4_aligned_2>(d_idata, d_odata, 32, MemorySize);
printf("uint8_misaligned...\n");
nTotalFailures += runTest<uint8_misaligned>(d_idata, d_odata, 32, MemorySize);

printf("uint8_aligned...\n");
nTotalFailures += runTest<uint8_aligned>(d_idata, d_odata, 32, MemorySize);

printf("\n[alignedTypes] -> Test Results: %d Failures\n", nTotalFailures);

Expand Down
16 changes: 12 additions & 4 deletions aligned-types-hip/main.cu
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ typedef struct
unsigned int r, g, b, a;
} uint4_misaligned;

typedef struct
{
uint4_misaligned c1, c2;
}
uint8_misaligned;


////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -97,7 +102,7 @@ typedef struct __align__(16)
{
uint4_aligned c1, c2;
}
uint4_aligned_2;
uint8_aligned;



Expand Down Expand Up @@ -211,7 +216,7 @@ template<class TData> int runTest(
dim3 block (256);
for (int i = 0; i < NUM_ITERATIONS; i++)
{
hipLaunchKernelGGL(HIP_KERNEL_NAME(testKernel<TData>), grid, block, 0, 0,
testKernel<TData><<<grid, block>>>(
(TData *)d_odata,
(TData *)d_idata,
numElements
Expand Down Expand Up @@ -303,8 +308,11 @@ int main(int argc, char **argv)
printf("uint4_aligned...\n");
nTotalFailures += runTest<uint4_aligned>(d_idata, d_odata, 16, MemorySize);

printf("uint4_aligned_2...\n");
nTotalFailures += runTest<uint4_aligned_2>(d_idata, d_odata, 32, MemorySize);
printf("uint8_misaligned...\n");
nTotalFailures += runTest<uint8_misaligned>(d_idata, d_odata, 32, MemorySize);

printf("uint8_aligned...\n");
nTotalFailures += runTest<uint8_aligned>(d_idata, d_odata, 32, MemorySize);

printf("\n[alignedTypes] -> Test Results: %d Failures\n", nTotalFailures);

Expand Down
13 changes: 10 additions & 3 deletions aligned-types-omp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ typedef struct
unsigned int r, g, b, a;
} uint4_misaligned;

typedef struct
{
uint4_misaligned c1, c2;
} uint8_misaligned;


////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -97,7 +101,7 @@ typedef struct __attribute__((__aligned__(16)))
{
uint4_aligned c1, c2;
}
uint4_aligned_2;
uint8_aligned;



Expand Down Expand Up @@ -280,8 +284,11 @@ int main(int argc, char **argv)
printf("uint4_aligned...\n");
nTotalFailures += runTest<uint4_aligned>(d_idata, d_odata, 16, MemorySize);

printf("uint4_aligned_2...\n");
nTotalFailures += runTest<uint4_aligned_2>(d_idata, d_odata, 32, MemorySize);
printf("uint8_misaligned...\n");
nTotalFailures += runTest<uint8_misaligned>(d_idata, d_odata, 32, MemorySize);

printf("uint8_aligned...\n");
nTotalFailures += runTest<uint8_aligned>(d_idata, d_odata, 32, MemorySize);

printf("\n[alignedTypes] -> Test Results: %d Failures\n", nTotalFailures);

Expand Down

0 comments on commit 299d235

Please sign in to comment.