1. added double dash option to test to avoid warning message about compilation database

2. fixed cmake resource folder discovery for standalone build case
This commit is contained in:
dfukalov
2016-03-05 13:59:38 +03:00
parent 236c38719c
commit d60aa72f6c
3 changed files with 14 additions and 13 deletions
+1
View File
@@ -53,6 +53,7 @@ if(${HIPIFY_STANDLONE})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -pthread -fno-rtti -fvisibility-inlines-hidden") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -pthread -fno-rtti -fvisibility-inlines-hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHIPIFY_CLANG_RES=\\\"${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}\\\"")
add_subdirectory(test) add_subdirectory(test)
else() else()
install(TARGETS hipify install(TARGETS hipify
+3
View File
@@ -685,6 +685,9 @@ int main(int argc, const char **argv) {
{ {
Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster(Stage, ArgumentInsertPosition::BEGIN)); Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster(Stage, ArgumentInsertPosition::BEGIN));
Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-std=c++11")); Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-std=c++11"));
#if defined(HIPIFY_CLANG_RES)
Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-resource-dir=" HIPIFY_CLANG_RES));
#endif // defined(HIPIFY_CLANG_HEADERS)
Tool.appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster()); Tool.appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster());
Result = Tool.run(action.get()); Result = Tool.run(action.get());
+10 -13
View File
@@ -1,11 +1,10 @@
// RUN: hipify "%s" 2>&1 | FileCheck %s // RUN: hipify "%s" -o=%t --
// RUN: FileCheck %s -input-file=%t --match-full-lines
#include <helper_cuda.h> // for checkCudaErrors
#include <iostream> #include <iostream>
__global__ void axpy(float a, float* x, float* y) { __global__ void axpy(float a, float* x, float* y) {
// CHECK: hipThreadIdx_x // CHECK: y[hipThreadIdx_x] = a * x[hipThreadIdx_x];
y[threadIdx.x] = a * x[threadIdx.x]; y[threadIdx.x] = a * x[threadIdx.x];
} }
@@ -19,25 +18,23 @@ int main(int argc, char* argv[]) {
// Copy input data to device. // Copy input data to device.
float* device_x; float* device_x;
float* device_y; float* device_y;
checkCudaErrors(cudaMalloc(&device_x, kDataLen * sizeof(float))); cudaMalloc(&device_x, kDataLen * sizeof(float));
checkCudaErrors(cudaMalloc(&device_y, kDataLen * sizeof(float))); cudaMalloc(&device_y, kDataLen * sizeof(float));
checkCudaErrors(cudaMemcpy(device_x, host_x, kDataLen * sizeof(float), cudaMemcpy(device_x, host_x, kDataLen * sizeof(float), cudaMemcpyHostToDevice);
cudaMemcpyHostToDevice));
// Launch the kernel. // Launch the kernel.
// CHECK: hipLaunchKernel(HIP_KERNEL_NAME // CHECK: hipLaunchKernel(HIP_KERNEL_NAME(axpy), dim3(1), dim3(kDataLen), 0, 0, a, device_x, device_y);
axpy<<<1, kDataLen>>>(a, device_x, device_y); axpy<<<1, kDataLen>>>(a, device_x, device_y);
// Copy output data to host. // Copy output data to host.
checkCudaErrors(cudaDeviceSynchronize()); cudaDeviceSynchronize();
checkCudaErrors(cudaMemcpy(host_y, device_y, kDataLen * sizeof(float), cudaMemcpy(host_y, device_y, kDataLen * sizeof(float), cudaMemcpyDeviceToHost);
cudaMemcpyDeviceToHost));
// Print the results. // Print the results.
for (int i = 0; i < kDataLen; ++i) { for (int i = 0; i < kDataLen; ++i) {
std::cout << "y[" << i << "] = " << host_y[i] << "\n"; std::cout << "y[" << i << "] = " << host_y[i] << "\n";
} }
checkCudaErrors(cudaDeviceReset()); cudaDeviceReset();
return 0; return 0;
} }