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
return hipHostMalloc( (void **) pp, N, Flags ); 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 #endif
// entry points // entry points
#define cudaDeviceMapHost hipDeviceMapHost #define cudaDeviceMapHost hipDeviceMapHost
#define cudaFree hipFree #define cudaFree hipFree
#define cudaHostFree hipHostFree #define cudaHostFree hipHostFree
#define cudaHostGetDevicePointer hipHostGetDevicePointer
#define cudaStreamDestroy hipStreamDestroy
#define cudaEventDestroy hipEventDestroy #define cudaEventDestroy hipEventDestroy
// data types
typedef hipStream_t cudaStream_t;
// defines
#define cudaMemcpyHostToDevice hipMemcpyHostToDevice #define cudaMemcpyHostToDevice hipMemcpyHostToDevice
#define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost #define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost
#define cudaMemcpyDeviceToDevice hipMemcpyDeviceToDevice #define cudaMemcpyDeviceToDevice hipMemcpyDeviceToDevice
#define cudaHostAllocMapped 0
// error defines // error defines
#define cudaSuccess hipSuccess #define cudaSuccess hipSuccess
#define cudaErrorUnknown hipErrorUnknown #define cudaErrorUnknown hipErrorUnknown
#define cudaErrorInvalidValue hipErrorInvalidValue
#define cudaErrorMemoryAllocation hipErrorMemoryAllocation #define cudaErrorMemoryAllocation hipErrorMemoryAllocation
#else #else

6
streaming/stream3Streams.cu

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

10
streaming/stream4Mapped.cu

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

10
streaming/stream5MappedXfer.cu

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

Loading…
Cancel
Save