Merge branch 'privatestaging' of https://github.com/AMDComputeLibraries/HIP-privatestaging into privatestaging

Conflicts:
	src/hip_hcc.cpp


[ROCm/hip commit: d07b347cac]
This commit is contained in:
Ben Sander
2016-03-23 03:22:09 -05:00
7 changed files with 92 additions and 19 deletions
@@ -18,7 +18,7 @@
| `cudaGetDevice` | `hipGetDevice` | Returns which device is currently being used. |
| `cudaGetDeviceCount` | `hipGetDeviceCount` | Returns the number of compute-capable devices. |
| `cudaGetDeviceFlags` | | Gets the flags for the current device. |
| `cudaGetDeviceProperties` | `hipDeviceGetProperties` | Returns information about the compute-device. |
| `cudaGetDeviceProperties` | `hipGetDeviceProperties` | Returns information about the compute-device. |
| `cudaIpcCloseMemHandle` | | Close memory mapped with cudaIpcOpenMemHandle. |
| `cudaIpcGetEventHandle` | | Gets an interprocess handle for a previously allocated event. |
| `cudaIpcGetMemHandle` | | Gets an interprocess memory handle for an existing device memory allocation. |
@@ -97,7 +97,7 @@
| `cudaGetMipmappedArrayLevel` | | Gets a mipmap level of a CUDA mipmapped array. |
| `cudaGetSymbolAddress` | | Finds the address associated with a CUDA symbol. |
| `cudaGetSymbolSize` | | Finds the size of the object associated with a CUDA symbol. |
| `cudaHostAlloc` | `hipHostAlloc` | Allocates page-locked memory on the host. |
| `cudaHostAlloc` | `hipHostMalloc` | Allocates page-locked memory on the host. |
| `cudaHostGetDevicePointer` | `hipHostGetDevicePointer` | Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister. |
| `cudaHostGetFlags` | `hipHostGetFlags` | Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc. |
| `cudaHostRegister` | | Registers an existing host memory range for use by CUDA. |
@@ -106,7 +106,7 @@
| `cudaMalloc3D` | | Allocates logical 1D, 2D, or 3D memory objects on the device. |
| `cudaMalloc3DArray` | | Allocate an array on the device. |
| `cudaMallocArray` | | Allocate an array on the device. |
| `cudaMallocHost` | `hipHostAlloc` | Allocates page-locked memory on the host. |
| `cudaMallocHost` | `hipHostMalloc` | Allocates page-locked memory on the host. |
| `cudaMallocManaged` | | Allocates memory that will be automatically managed by the Unified Memory system. |
| `cudaMallocMipmappedArray` | | Allocate a mipmapped array on the device. |
| `cudaMallocPitch` | | Allocates pitched memory on the device. |
@@ -688,10 +688,10 @@ hipError_t hipHostAlloc(void** ptr, size_t size, unsigned int flags) __attribute
*
* @param[out] dstPtr Device Pointer mapped to passed host pointer
* @param[in] hstPtr Host Pointer allocated through hipHostAlloc
* @param[in] size Requested memory size
* @param[in] flags Flags to be passed for extension
* @return Error code
*/
hipError_t hipHostGetDevicePointer(void** devPtr, void* hstPtr, size_t size) ;
hipError_t hipHostGetDevicePointer(void** devPtr, void* hstPtr, unsigned int flags) ;
/**
* @brief Get flags associated with host pointer
+2
View File
@@ -149,6 +149,8 @@ typedef enum hipError_t {
,hipErrorInvalidResourceHandle ///< Resource handle (hipEvent_t or hipStream_t) invalid.
,hipErrorInvalidDevice ///< DeviceID must be in range 0...#compute-devices.
,hipErrorInvalidMemcpyDirection ///< Invalid memory copy direction
,hipErrorInvalidDevicePointer ///< Invalid Device Pointer
,hipErrorInitializationError ///< TODO comment from hipErrorInitializationError
,hipErrorNoDevice ///< Call to hipGetDeviceCount returned 0 devices
,hipErrorNotReady ///< Indicates that asynchronous operations enqueued earlier are not ready. This is not actually an error, but is used to distinguish from hipSuccess (which indicates completion). APIs that return this error include hipEventQuery and hipStreamQuery.
@@ -50,10 +50,10 @@ hipMemcpyHostToHost
} hipTextureFilterMode;*/
#define hipFilterModePoint cudaFilterModePoint
#define hipHostAllocDefault cudaHostAllocDefault
#define hipHostAllocPortable cudaHostAllocPortable
#define hipHostAllocMapped cudaHostAllocMapped
#define hipHostAllocWriteCombined cudaHostAllocWriteCombined
#define hipHostMallocDefault cudaHostAllocDefault
#define hipHostMallocPortable cudaHostAllocPortable
#define hipHostMallocMapped cudaHostAllocMapped
#define hipHostMallocWriteCombined cudaHostAllocWriteCombined
#define hipHostRegisterPortable cudaHostRegisterPortable
#define hipHostRegisterMapped cudaHostRegisterMapped
+22 -6
View File
@@ -2699,16 +2699,24 @@ hipError_t hipFree(void* ptr)
{
HIP_INIT_API(ptr);
// TODO - ensure this pointer was created by hipMalloc and not hipMallocHost
hipError_t hipStatus = hipErrorInvalidDevicePointer;
// Synchronize to ensure all work has finished.
ihipGetTlsDefaultDevice()->waitAllStreams(); // ignores non-blocking streams, this waits for all activity to finish.
if (ptr) {
hc::am_free(ptr);
hc::accelerator acc;
hc::AmPointerInfo amPointerInfo(NULL, NULL, 0, acc, 0, 0);
am_status_t status = hc::am_memtracker_getinfo(&amPointerInfo, ptr);
if(status == AM_SUCCESS){
if(amPointerInfo._hostPointer == NULL){
hc::am_free(ptr);
hipStatus = hipSuccess;
}
}
}
return ihipLogStatus(hipSuccess);
return ihipLogStatus(hipStatus);
}
@@ -2719,12 +2727,20 @@ hipError_t hipHostFree(void* ptr)
// TODO - ensure this pointer was created by hipMallocHost and not hipMalloc
std::call_once(hip_initialized, ihipInit);
hipError_t hipStatus = hipErrorInvalidDevicePointer;
if (ptr) {
tprintf (DB_MEM, " %s: %p\n", __func__, ptr);
hc::am_free(ptr);
hc::accelerator acc;
hc::AmPointerInfo amPointerInfo(NULL, NULL, 0, acc, 0, 0);
am_status_t status = hc::am_memtracker_getinfo(&amPointerInfo, ptr);
if(status == AM_SUCCESS){
if(amPointerInfo._hostPointer == ptr){
hc::am_free(ptr);
hipStatus = hipSuccess;
}
}
}
return ihipLogStatus(hipSuccess);
return ihipLogStatus(hipStatus);
};
+8 -4
View File
@@ -116,8 +116,8 @@ macro (make_test_matches exe match_string)
)
endmacro()
make_hip_executable (hipAPIStreamEnable hipAPIStreamEnable.cpp)
make_hip_executable (hipAPIStreamDisable hipAPIStreamDisable.cpp)
#make_hip_executable (hipAPIStreamEnable hipAPIStreamEnable.cpp)
#make_hip_executable (hipAPIStreamDisable hipAPIStreamDisable.cpp)
make_hip_executable (hip_ballot hip_ballot.cpp)
make_hip_executable (hip_anyall hip_anyall.cpp)
make_hip_executable (hip_popc hip_popc.cpp)
@@ -148,6 +148,8 @@ make_hip_executable (hipStreamL5 hipStreamL5.cpp)
make_hip_executable (hipHostGetFlags hipHostGetFlags.cpp)
make_hip_executable (hipHostRegister hipHostRegister.cpp)
make_hip_executable (hipRandomMemcpyAsync hipRandomMemcpyAsync.cpp)
make_hip_executable (hipMemoryAllocate hipMemoryAllocate.cpp)
make_test(hip_ballot " " )
make_test(hip_anyall " " )
make_test(hip_popc " " )
@@ -180,6 +182,8 @@ make_test(hipHcc " " )
make_test(hipHostRegister " ")
make_test(hipStreamL5 " ")
make_test(hipRandomMemcpyAsync " ")
make_test(hipAPIStreamEnable " ")
make_test(hipAPIStreamDisable " ")
#make_test(hipAPIStreamEnable " ")
#make_test(hipAPIStreamDisable " ")
make_test(hipMemoryAllocate " ")
make_hipify_test(specialFunc.cu )
@@ -0,0 +1,51 @@
/*
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
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.
*/
#include"test_common.h"
#define SIZE 1024*1024*256
int main(){
float *Ad, *B, *Bd, *Bm, *C, *Cd;
B = (float*)malloc(SIZE);
hipMalloc((void**)&Ad, SIZE);
hipHostMalloc((void**)&B, SIZE);
hipHostMalloc((void**)&Bd, SIZE, hipHostMallocDefault);
hipHostMalloc((void**)&Bm, SIZE, hipHostMallocMapped);
hipHostMalloc((void**)&C, SIZE, hipHostMallocMapped);
hipHostGetDevicePointer((void**)&Cd, C, SIZE);
HIPASSERT(hipFree(Ad) == hipSuccess);
HIPASSERT(hipHostFree(Ad) == hipErrorInvalidDevicePointer);
HIPASSERT(hipFree(B) == hipErrorInvalidDevicePointer);
HIPASSERT(hipFree(Bd) == hipErrorInvalidDevicePointer);
HIPASSERT(hipFree(Bm) == hipErrorInvalidDevicePointer);
HIPASSERT(hipHostFree(Bd) == hipSuccess);
HIPASSERT(hipHostFree(Bm) == hipSuccess);
HIPASSERT(hipFree(C) == hipErrorInvalidDevicePointer);
HIPASSERT(hipFree(Cd) == hipErrorInvalidDevicePointer);
HIPASSERT(hipHostFree(C) == hipSuccess);
HIPASSERT(hipHostFree(Cd) == hipErrorInvalidDevicePointer);
HIPASSERT(hipFree(Cd) == hipErrorInvalidDevicePointer);
HIPASSERT(hipFree(NULL) == hipErrorInvalidDevicePointer);
HIPASSERT(hipHostFree(NULL) == hipErrorInvalidDevicePointer);
passed();
}