[HIPIFY] Introduce CUDA installation path option '-cuda-path'
Repeats clang's '--cuda-path' option. [Reason] In case of absence of any other clang's options setting '-cuda-path' allows not to specify separator '--' before clang's '--cuda-path'. + Tests and scripts are updated accordingly.
This commit is contained in:
@@ -39,6 +39,11 @@ cl::opt<std::string> TemporaryDir("temp-dir",
|
||||
cl::value_desc("directory"),
|
||||
cl::cat(ToolTemplateCategory));
|
||||
|
||||
cl::opt<std::string> CudaPath("cuda-path",
|
||||
cl::desc("CUDA installation path"),
|
||||
cl::value_desc("directory"),
|
||||
cl::cat(ToolTemplateCategory));
|
||||
|
||||
cl::opt <bool> SaveTemps("save-temps",
|
||||
cl::desc("Save temporary files"),
|
||||
cl::value_desc("save-temps"),
|
||||
|
||||
@@ -32,6 +32,7 @@ extern cl::OptionCategory ToolTemplateCategory;
|
||||
extern cl::opt<std::string> OutputFilename;
|
||||
extern cl::opt<std::string> OutputDir;
|
||||
extern cl::opt<std::string> TemporaryDir;
|
||||
extern cl::opt<std::string> CudaPath;
|
||||
extern cl::opt<bool> Inplace;
|
||||
extern cl::opt<bool> SaveTemps;
|
||||
extern cl::opt<bool> NoBackup;
|
||||
|
||||
@@ -174,6 +174,10 @@ int main(int argc, const char **argv) {
|
||||
Tool.appendArgumentsAdjuster(ct::getInsertArgumentAdjuster("cuda", ct::ArgumentInsertPosition::BEGIN));
|
||||
Tool.appendArgumentsAdjuster(ct::getInsertArgumentAdjuster("-x", ct::ArgumentInsertPosition::BEGIN));
|
||||
Tool.appendArgumentsAdjuster(ct::getInsertArgumentAdjuster("--cuda-host-only", ct::ArgumentInsertPosition::BEGIN));
|
||||
if (!CudaPath.empty()) {
|
||||
std::string sCudaPath = "--cuda-path=" + CudaPath;
|
||||
Tool.appendArgumentsAdjuster(ct::getInsertArgumentAdjuster(sCudaPath.c_str(), ct::ArgumentInsertPosition::BEGIN));
|
||||
}
|
||||
// Includes for clang's CUDA wrappers for using by packaged hipify-clang
|
||||
Tool.appendArgumentsAdjuster(ct::getInsertArgumentAdjuster("./include", ct::ArgumentInsertPosition::BEGIN));
|
||||
Tool.appendArgumentsAdjuster(ct::getInsertArgumentAdjuster("-isystem", ct::ArgumentInsertPosition::BEGIN));
|
||||
|
||||
@@ -64,18 +64,20 @@ if obj_root is not None:
|
||||
config.environment['PATH'] = path
|
||||
|
||||
hipify_path = obj_root
|
||||
clang_args = "-v --cuda-path='%s'"
|
||||
|
||||
clang_arguments = "-v"
|
||||
if sys.platform in ['win32']:
|
||||
run_test_ext = ".bat"
|
||||
hipify_path += "/" + config.build_type
|
||||
clang_args += " -isystem'%s'/common/inc"
|
||||
clang_arguments += " -isystem'%s'/common/inc"
|
||||
else:
|
||||
run_test_ext = ".sh"
|
||||
clang_args += " -isystem'%s'/samples/common/inc"
|
||||
clang_arguments += " -isystem'%s'/samples/common/inc"
|
||||
clang_arguments += " -I'%s'/include"
|
||||
|
||||
clang_args += " -I'%s'/include"
|
||||
hipify_arguments = "-cuda-path='%s'"
|
||||
|
||||
config.substitutions.append(("%cuda_args", clang_args % (config.cuda_root, config.cuda_sdk_root, config.cuda_dnn_root)))
|
||||
config.substitutions.append(("%clang_args", clang_arguments % (config.cuda_sdk_root, config.cuda_dnn_root)))
|
||||
config.substitutions.append(("%hipify_args", hipify_arguments % (config.cuda_root)))
|
||||
config.substitutions.append(("hipify", '"' + hipify_path + "/hipify-clang" + '"'))
|
||||
config.substitutions.append(("%run_test", '"' + config.test_source_root + "/run_test" + run_test_ext + '"'))
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
setlocal
|
||||
|
||||
for %%i in (FileCheck.exe) do set FILE_CHECK=%%~$PATH:i
|
||||
if not defined FILE_CHECK (echo Error: FileCheck.exe not found in PATH. && exit /b 1)
|
||||
if not defined FILE_CHECK (echo Error: FileCheck.exe not found in PATH. && exit /b 1)
|
||||
|
||||
set HIPIFY=%1
|
||||
set IN_FILE=%2
|
||||
set TMP_FILE=%3
|
||||
set CUDA_ROOT=%4
|
||||
|
||||
set all_args=%*
|
||||
call set clang_args=%%all_args:*%4=%%
|
||||
set clang_args=%4%clang_args%
|
||||
call set clang_args=%%all_args:*%5=%%
|
||||
set clang_args=%5%clang_args%
|
||||
|
||||
%HIPIFY% -o=%TMP_FILE% %IN_FILE% -- %clang_args%
|
||||
%HIPIFY% -o=%TMP_FILE% %IN_FILE% %CUDA_ROOT% -- %clang_args%
|
||||
if errorlevel 1 (echo Error: hipify-clang.exe failed with exit code: %errorlevel% && exit /b %errorlevel%)
|
||||
|
||||
findstr /v /r /c:"[ ]*//[ ]*[CHECK*|RUN]" %TMP_FILE% | %FILE_CHECK% %IN_FILE%
|
||||
|
||||
@@ -9,9 +9,9 @@ set -o errexit
|
||||
HIPIFY=$1
|
||||
IN_FILE=$2
|
||||
TMP_FILE=$3
|
||||
shift 3
|
||||
CUDA_ROOT=$4
|
||||
shift 4
|
||||
|
||||
# Remaining args are the ones to forward to clang proper.
|
||||
|
||||
$HIPIFY -o=$TMP_FILE $IN_FILE -- $@ && cat $TMP_FILE | sed -Ee 's|//.+|// |g' | FileCheck $IN_FILE
|
||||
|
||||
$HIPIFY -o=$TMP_FILE $IN_FILE $CUDA_ROOT -- $@ && cat $TMP_FILE | sed -Ee 's|//.+|// |g' | FileCheck $IN_FILE
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
// CHECK-NOT: #include <cuda_runtime.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include "hip/hip_runtime.h"
|
||||
// CHECK-NOT: #include "cuda_runtime.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #pragma once
|
||||
// CHECK-NEXT: #include <hip/hip_runtime.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
// CHECK-NEXT: #include <stdio.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #pragma once
|
||||
// CHECK-NEXT: #include <hip/hip_runtime.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include <hipblas.h>
|
||||
// CHECK-NOT: #include <cublas_v2.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include "hipblas.h"
|
||||
// CHECK-NOT: #include "cublas.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
// CHECK-NOT: #include <cuda_runtime.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
// CHECK: #include <memory>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
// CHECK: #include "hip/hip_complex.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
#include <cuda.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// Taken from: http://docs.nvidia.com/cuda/curand/device-api-overview.html#poisson-api-example
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// To measure effects of memory coalescing. Coalescing.cu
|
||||
// B. Wilkinson Jan 30, 2011
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
/*
|
||||
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// Taken from Jonathan Hui blog https://jhui.github.io/2017/03/06/CUDA
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
/*
|
||||
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// Taken from Jonathan Hui blog https://jhui.github.io/2017/03/06/CUDA
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %cuda_args
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
|
||||
|
||||
// Kernel definition
|
||||
__global__ void vecAdd(float* A, float* B, float* C)
|
||||
|
||||
Reference in New Issue
Block a user