Browse Source

Continue porting stream samples to HIP

hipcc
Nicholas Wilt 3 years ago
parent
commit
bdae5e7544
  1. 13
      chLib/chError.h
  2. 6
      streaming/stream3Streams.cu
  3. 10
      streaming/stream4Mapped.cu
  4. 10
      streaming/stream5MappedXfer.cu

13
chLib/chError.h

@ -71,21 +71,34 @@ template<typename T> hipError_t hipHostAlloc( T **pp, size_t N, unsigned int Fla @@ -71,21 +71,34 @@ template<typename T> hipError_t hipHostAlloc( T **pp, size_t N, unsigned int Fla
return hipHostMalloc( (void **) pp, N, Flags );
}
template<typename T> hipError_t hipHostGetDevicePointer( T **pp, void *p, unsigned int Flags ) {
return hipHostGetDevicePointer( (void **) pp, p, Flags );
}
#endif
// entry points
#define cudaDeviceMapHost hipDeviceMapHost
#define cudaFree hipFree
#define cudaHostFree hipHostFree
#define cudaHostGetDevicePointer hipHostGetDevicePointer
#define cudaStreamDestroy hipStreamDestroy
#define cudaEventDestroy hipEventDestroy
// data types
typedef hipStream_t cudaStream_t;
// defines
#define cudaMemcpyHostToDevice hipMemcpyHostToDevice
#define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost
#define cudaMemcpyDeviceToDevice hipMemcpyDeviceToDevice
#define cudaHostAllocMapped 0
// error defines
#define cudaSuccess hipSuccess
#define cudaErrorUnknown hipErrorUnknown
#define cudaErrorInvalidValue hipErrorInvalidValue
#define cudaErrorMemoryAllocation hipErrorMemoryAllocation
#else

6
streaming/stream3Streams.cu

@ -158,9 +158,9 @@ Error: @@ -158,9 +158,9 @@ Error:
cudaFree( dptrOut );
cudaFree( dptrX );
cudaFree( dptrY );
cudaFreeHost( hptrOut );
cudaFreeHost( hptrX );
cudaFreeHost( hptrY );
cudaHostFree( hptrOut );
cudaHostFree( hptrX );
cudaHostFree( hptrY );
return status;
}

10
streaming/stream4Mapped.cu

@ -77,8 +77,8 @@ MeasureTimes( @@ -77,8 +77,8 @@ MeasureTimes(
cuda(EventCreate( &evStart ) );
cuda(EventCreate( &evStop ) );
for ( size_t i = 0; i < N; i++ ) {
hptrX[i] = (float) rand() / RAND_MAX;
hptrY[i] = (float) rand() / RAND_MAX;
hptrX[i] = (float) ((double) rand() / RAND_MAX);
hptrY[i] = (float) ((double) rand() / RAND_MAX);
}
//
@ -107,9 +107,9 @@ MeasureTimes( @@ -107,9 +107,9 @@ MeasureTimes(
Error:
cudaEventDestroy( evStop );
cudaEventDestroy( evStart );
cudaFreeHost( hptrOut );
cudaFreeHost( hptrX );
cudaFreeHost( hptrY );
cudaHostFree( hptrOut );
cudaHostFree( hptrX );
cudaHostFree( hptrY );
return status;
}

10
streaming/stream5MappedXfer.cu

@ -75,8 +75,8 @@ MeasureTimes( @@ -75,8 +75,8 @@ MeasureTimes(
cuda(EventCreate( &evStart ) );
cuda(EventCreate( &evStop ) );
for ( size_t i = 0; i < N; i++ ) {
hptrX[i] = (float) rand() / RAND_MAX;
hptrY[i] = (float) rand() / RAND_MAX;
hptrX[i] = (float) ((double) rand() / RAND_MAX);
hptrY[i] = (float) ((double) rand() / RAND_MAX);
}
//
@ -107,9 +107,9 @@ Error: @@ -107,9 +107,9 @@ Error:
cudaEventDestroy( evStop );
cudaEventDestroy( evStart );
cudaFree( dptrOut );
cudaFreeHost( hptrOut );
cudaFreeHost( hptrX );
cudaFreeHost( hptrY );
cudaHostFree( hptrOut );
cudaHostFree( hptrX );
cudaHostFree( hptrY );
return status;
}

Loading…
Cancel
Save