Fixed bit_extract
Change-Id: I92d7b7a302e3fa0db84889fb5dc6b612e6a53c73
This commit is contained in:
@@ -24,4 +24,3 @@ $(EXE): bit_extract.cpp
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o $(EXE)
|
rm -f *.o $(EXE)
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ THE SOFTWARE.
|
|||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
void __global__
|
__global__ void
|
||||||
bit_extract_kernel(hipLaunchParm lp, uint32_t *C_d, const uint32_t *A_d, size_t N)
|
bit_extract_kernel(hipLaunchParm lp, uint32_t *C_d, const uint32_t *A_d, size_t N)
|
||||||
{
|
{
|
||||||
size_t offset = (hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x);
|
size_t offset = (hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x);
|
||||||
@@ -45,7 +45,7 @@ bit_extract_kernel(hipLaunchParm lp, uint32_t *C_d, const uint32_t *A_d, size_t
|
|||||||
|
|
||||||
for (size_t i=offset; i<N; i+=stride) {
|
for (size_t i=offset; i<N; i+=stride) {
|
||||||
#ifdef __HIP_PLATFORM_HCC__
|
#ifdef __HIP_PLATFORM_HCC__
|
||||||
C_d[i] = hc::__bitextract_u32(A_d[i], 8, 4);
|
C_d[i] = hc::__bitextract_u32(A_d[i], 8, 4);
|
||||||
#else /* defined __HIP_PLATFORM_NVCC__ or other path */
|
#else /* defined __HIP_PLATFORM_NVCC__ or other path */
|
||||||
C_d[i] = ((A_d[i] & 0xf00) >> 8);
|
C_d[i] = ((A_d[i] & 0xf00) >> 8);
|
||||||
#endif
|
#endif
|
||||||
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
|
|||||||
C_h = (uint32_t*)malloc(Nbytes);
|
C_h = (uint32_t*)malloc(Nbytes);
|
||||||
CHECK(C_h == 0 ? hipErrorMemoryAllocation : hipSuccess );
|
CHECK(C_h == 0 ? hipErrorMemoryAllocation : hipSuccess );
|
||||||
|
|
||||||
for (size_t i=0; i<N; i++)
|
for (size_t i=0; i<N; i++)
|
||||||
{
|
{
|
||||||
A_h[i] = i;
|
A_h[i] = i;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user