Skip to content

Commit

Permalink
Merge branch 'oneapi-src:SYCLomatic' into migrate_utils_groups
Browse files Browse the repository at this point in the history
  • Loading branch information
abhilash1910 authored May 27, 2024
2 parents ba14654 + e5795a8 commit c7f3594
Show file tree
Hide file tree
Showing 23 changed files with 261 additions and 66 deletions.
7 changes: 7 additions & 0 deletions clang/examples/DPCT/NCCL/ncclCommGetAsyncError.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <nccl.h>

void test(ncclComm_t comm, ncclResult_t *r) {
// Start
ncclCommGetAsyncError(comm /*ncclComm_t*/, r /*ncclResult_t **/);
// End
}
7 changes: 7 additions & 0 deletions clang/examples/DPCT/NCCL/ncclGetErrorString.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <nccl.h>

void test(ncclResult_t r) {
// Start
ncclGetErrorString(r /*ncclResult_t*/);
// End
}
7 changes: 7 additions & 0 deletions clang/examples/DPCT/NCCL/ncclGetLastError.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <nccl.h>

void test(ncclComm_t comm) {
// Start
ncclGetLastError(comm /*ncclComm_t*/);
// End
}
9 changes: 9 additions & 0 deletions clang/examples/DPCT/NCCL/ncclRecv.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <nccl.h>

void test(void *sendbuff, size_t count, ncclDataType_t datatype, int peer,
ncclComm_t comm, cudaStream_t stream) {
// Start
ncclRecv(sendbuff /*void **/, count /*size_t*/, datatype /*ncclDataType_t*/,
peer /*int*/, comm /*ncclComm_t*/, stream /*cudaStream_t*/);
// End
}
10 changes: 10 additions & 0 deletions clang/examples/DPCT/NCCL/ncclSend.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <nccl.h>

void test(const void *sendbuff, size_t count, ncclDataType_t datatype, int peer,
ncclComm_t comm, cudaStream_t stream) {
// Start
ncclSend(sendbuff /*const void **/, count /*size_t*/,
datatype /*ncclDataType_t*/, peer /*int*/, comm /*ncclComm_t*/,
stream /*cudaStream_t*/);
// End
}
18 changes: 17 additions & 1 deletion clang/lib/DPCT/PatternRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,21 @@ static int parseCodeElement(const MatchPattern &Suffix,
delimiters.
*/

if (SrcFileType == SourceFileType::SFT_CMakeScript) {
if (Index - 1 >= 0 && Character == '"' && Input[Index - 1] == '\\') {
Index++;
while (Index < Size &&
!(Input[Index - 1] == '\\' && Input[Index] == '"')) {
Index++;
}
if (Index >= Size) {
return -1;
}
Index++;
continue;
}
}

if (Character == '\'') {
Index++;
while (Index < Size &&
Expand Down Expand Up @@ -467,7 +482,8 @@ static std::optional<MatchResult> findFullMatch(const MatchPattern &Pattern,
!isWhitespace(Input[Index - PatternSize]) &&
!isWhitespace(Input[Index + 1]) &&
Input[Index - PatternSize] != '*' &&
Input[Index - PatternSize] != '"') {
Input[Index - PatternSize] != '"' &&
Input[Index - PatternSize] != ';' && Input[Index + 1] != '\\') {
return {};
}
}
Expand Down
9 changes: 3 additions & 6 deletions clang/test/dpct/cmake_migration/case_004/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ target_link_libraries(${target} PRIVATE

)

target_link_libraries(${PROJECT_NAME}


)
target_link_libraries(nlm_cuda ${OpenCV_LIBS} stdc++ stdc++fs)
target_link_libraries(${PROJECT_NAME} )
target_link_libraries(nlm_cuda ${OpenCV_LIBS} stdc++ stdc++fs)
target_link_libraries(cublas-cudnn-test ${MKL_LIB} ${DNN_LIB})

target_link_libraries(tsne ${MKL_LIB} ${MKL_LIB} ${MKL_LIB})
target_link_libraries(tsne ${MKL_LIB} ${MKL_LIB} ${MKL_LIB})
1 change: 1 addition & 0 deletions clang/test/dpct/cmake_migration/case_021/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
add_link_options("")
list(APPEND PMEMD_NVCC_FLAGS --std c++17)
1 change: 1 addition & 0 deletions clang/test/dpct/cmake_migration/case_021/input.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
add_link_options("--add-arch=sm_70")
list(APPEND PMEMD_NVCC_FLAGS --std c++11)
2 changes: 2 additions & 0 deletions clang/test/dpct/cmake_migration/case_024/expected.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
set(SYCL_HAS_FP16 TRUE)
file(WRITE ${output_file} "SET(SYCL_HAS_FP16\n TRUE)\n\n")
file(WRITE ${output_file} "SET(SYCL_HAS_FP16 TRUE)\n\n")
2 changes: 2 additions & 0 deletions clang/test/dpct/cmake_migration/case_024/input.cmake
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
set(CUDA_HAS_FP16 TRUE)
file(WRITE ${output_file} "SET(CUDA_HAS_FP16\n TRUE)\n\n")
file(WRITE ${output_file} "SET(CUDA_HAS_FP16 TRUE)\n\n")
8 changes: 8 additions & 0 deletions clang/test/dpct/cmake_migration/case_027/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ if (NOT SYCL_HOST_COMPILER STREQUAL "")
endif()
set(CMAKE_SYCL_ARCHITECTURES "")
set(CMAKE_SYCL_FLAGS "")

add_custom_command(
COMMAND ${CMAKE_COMMAND} -E echo \"\#endif // define ${HEADER_FILE_DEFINE}\" >> ${OUTPUT_HEADER_FILE}
DEPENDS ${spv_file} xxd
COMMENT "Converting to hpp: ${FILE_NAME} ${CMAKE_BINARY_DIR}/bin/$<CONFIG>/xxd"
)
set(NVCC_CMD ${CMAKE_SYCL_COMPILER} .c)
string(REGEX REPLACE "^.* version ([0-9.]*).*$" "\\1" CUDA_CCVER ${CUDA_CCFULLVER})
8 changes: 8 additions & 0 deletions clang/test/dpct/cmake_migration/case_027/input.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ if (NOT CMAKE_CUDA_HOST_COMPILER STREQUAL "")
endif()
set(CMAKE_CUDA_ARCHITECTURES "")
set(CMAKE_CUDA_FLAGS "")

add_custom_command(
COMMAND ${CMAKE_COMMAND} -E echo \"\#endif // define ${HEADER_FILE_DEFINE}\" >> ${OUTPUT_HEADER_FILE}
DEPENDS ${spv_file} xxd
COMMENT "Converting to hpp: ${FILE_NAME} ${CMAKE_BINARY_DIR}/bin/$<CONFIG>/xxd"
)
set(NVCC_CMD ${CMAKE_CUDA_COMPILER} .c)
string(REGEX REPLACE "^.* version ([0-9.]*).*$" "\\1" CUDA_CCVER ${CUDA_CCFULLVER})
1 change: 1 addition & 0 deletions clang/test/dpct/cmake_migration/case_031/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ include_directories(${somePath} ../)
include_directories("${SYCL_INCLUDE_DIR}")
include_directories(" ${SYCL_INCLUDE_DIR}")
include_directories(" ${SYCL_INCLUDE_DIR}" )
string(APPEND var ";${SYCL_INCLUDE_DIR}")
1 change: 1 addition & 0 deletions clang/test/dpct/cmake_migration/case_031/input.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ include_directories(${somePath} ../)
include_directories("${CUDA_INCLUDE_DIRS}")
include_directories(" ${CUDA_INCLUDE_DIRS}")
include_directories(" ${CUDA_INCLUDE_DIRS}" )
string(APPEND var ";${CUDA_INCLUDE_DIRS}")
9 changes: 2 additions & 7 deletions clang/test/dpct/cmake_migration/case_032/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ set(LIBS ${LIBS}

)

target_link_libraries(${target}

${MKL_LIB}
target_link_libraries(${target} ${MKL_LIB}
${MKL_LIB}


Expand Down Expand Up @@ -89,10 +87,7 @@ set(LIBS ${LIBS}

)

target_link_libraries(${target}



target_link_libraries(${target}
${MKL_LIB}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
// RUN: cat %S/ref.txt > ./check.txt
// RUN: cat migration1.log >> ./check.txt
// RUN: FileCheck --match-full-lines --input-file check.txt check.txt
// RUN: cat %S/foo.cu > ./foo.cu
// RUN: cat %S/compile_commands.json > ./compile_commands.json
// RUN: dpct -in-root ./ -out-root out --cuda-include-path="%cuda-path/include" -p ./ --migrate-build-script=CMake > migration2.log 2>&1
// RUN: cat %S/ref.txt > ./check.txt
// RUN: cat migration2.log >> ./check.txt
// RUN: FileCheck --match-full-lines --input-file check.txt check.txt

void foo() {}

This file was deleted.

5 changes: 0 additions & 5 deletions clang/test/dpct/cmake_migration/case_051/foo.cu

This file was deleted.

54 changes: 48 additions & 6 deletions clang/test/dpct/query_api_mapping/NCCL/lit_nccl.cu
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/// Communicator Creation and Management Functions

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclGetLastError | FileCheck %s -check-prefix=NCCLGETLASTERROR
// NCCLGETLASTERROR: CUDA API:
// NCCLGETLASTERROR-NEXT: ncclGetLastError(comm /*ncclComm_t*/);
// NCCLGETLASTERROR-NEXT: The API is Removed.
// NCCLGETLASTERROR-EMPTY:

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclGetErrorString | FileCheck %s -check-prefix=NCCLGETERRORSTRING
// NCCLGETERRORSTRING: CUDA API:
// NCCLGETERRORSTRING-NEXT: ncclGetErrorString(r /*ncclResult_t*/);
// NCCLGETERRORSTRING-NEXT: Is migrated to:
// NCCLGETERRORSTRING-NEXT: /*
// NCCLGETERRORSTRING-NEXT: DPCT1009:0: SYCL uses exceptions to report errors and does not use the error codes. The call was replaced by a placeholder string. You need to rewrite this code.
// NCCLGETERRORSTRING-NEXT: */
// NCCLGETERRORSTRING-NEXT: "<Placeholder string>";

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclGetVersion | FileCheck %s -check-prefix=ncclGetVersion
// ncclGetVersion: CUDA API:
// ncclGetVersion-NEXT: ncclGetVersion(version /*int **/);
Expand All @@ -23,6 +40,12 @@
// ncclCommDestroy-NEXT: Is migrated to:
// ncclCommDestroy-NEXT: delete comm;

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclCommGetAsyncError | FileCheck %s -check-prefix=NCCLCOMMGETASYNCERROR
// NCCLCOMMGETASYNCERROR: CUDA API:
// NCCLCOMMGETASYNCERROR-NEXT: ncclCommGetAsyncError(comm /*ncclComm_t*/, r /*ncclResult_t **/);
// NCCLCOMMGETASYNCERROR-NEXT: The API is Removed.
// NCCLCOMMGETASYNCERROR-EMPTY:

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclCommCount | FileCheck %s -check-prefix=ncclCommCount
// ncclCommCount: CUDA API:
// ncclCommCount-NEXT: ncclCommCount(comm /*ncclComm_t*/, count /*int **/);
Expand All @@ -41,6 +64,8 @@
// ncclCommUserRank-NEXT: Is migrated to:
// ncclCommUserRank-NEXT: *rank = comm->rank();

/// Collective Communication Functions

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclAllReduce | FileCheck %s -check-prefix=ncclAllReduce
// ncclAllReduce: CUDA API:
// ncclAllReduce-NEXT: ncclAllReduce(sendbuff /*void **/, recvbuff /*void **/, count /*size_t*/,
Expand All @@ -57,6 +82,13 @@
// ncclBroadcast-NEXT: Is migrated to:
// ncclBroadcast-NEXT: comm->broadcast(sendbuff, recvbuff, count, datatype, root, stream);

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclBcast | FileCheck %s -check-prefix=ncclBcast
// ncclBcast: CUDA API:
// ncclBcast-NEXT: ncclBcast(buff /*void **/, count /*size_t*/, datatype /*ncclDataType_t*/,
// ncclBcast-NEXT: root /*int*/, comm /*ncclComm_t*/, stream /*cudaStream_t*/);
// ncclBcast-NEXT: Is migrated to:
// ncclBcast-NEXT: comm->broadcast(buff, buff, count, datatype, root, stream);

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclReduce | FileCheck %s -check-prefix=ncclReduce
// ncclReduce: CUDA API:
// ncclReduce-NEXT: ncclReduce(sendbuff /*void **/, recvbuff /*void **/, count /*size_t*/,
Expand All @@ -74,9 +106,19 @@
// ncclReduceScatter-NEXT: Is migrated to:
// ncclReduceScatter-NEXT: comm->reduce_scatter(sendbuff, recvbuff, recvcount, datatype, op, stream);

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclBcast | FileCheck %s -check-prefix=ncclBcast
// ncclBcast: CUDA API:
// ncclBcast-NEXT: ncclBcast(buff /*void **/, count /*size_t*/, datatype /*ncclDataType_t*/,
// ncclBcast-NEXT: root /*int*/, comm /*ncclComm_t*/, stream /*cudaStream_t*/);
// ncclBcast-NEXT: Is migrated to:
// ncclBcast-NEXT: comm->broadcast(buff, buff, count, datatype, root, stream);
/// Point To Point Communication Functions

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclSend | FileCheck %s -check-prefix=NCCLSEND
// NCCLSEND: CUDA API:
// NCCLSEND-NEXT: ncclSend(sendbuff /*const void **/, count /*size_t*/,
// NCCLSEND-NEXT: datatype /*ncclDataType_t*/, peer /*int*/, comm /*ncclComm_t*/,
// NCCLSEND-NEXT: stream /*cudaStream_t*/);
// NCCLSEND-NEXT: Is migrated to:
// NCCLSEND-NEXT: comm->send(sendbuff, count, datatype, peer, stream);

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=ncclRecv | FileCheck %s -check-prefix=NCCLRECV
// NCCLRECV: CUDA API:
// NCCLRECV-NEXT: ncclRecv(sendbuff /*void **/, count /*size_t*/, datatype /*ncclDataType_t*/,
// NCCLRECV-NEXT: peer /*int*/, comm /*ncclComm_t*/, stream /*cudaStream_t*/);
// NCCLRECV-NEXT: Is migrated to:
// NCCLRECV-NEXT: comm->recv(sendbuff, count, datatype, peer, stream);
5 changes: 5 additions & 0 deletions clang/test/dpct/query_api_mapping/test_all.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1844,12 +1844,17 @@
// CHECK-NEXT: ncclCommCount
// CHECK-NEXT: ncclCommCuDevice
// CHECK-NEXT: ncclCommDestroy
// CHECK-NEXT: ncclCommGetAsyncError
// CHECK-NEXT: ncclCommInitRank
// CHECK-NEXT: ncclCommUserRank
// CHECK-NEXT: ncclGetErrorString
// CHECK-NEXT: ncclGetLastError
// CHECK-NEXT: ncclGetUniqueId
// CHECK-NEXT: ncclGetVersion
// CHECK-NEXT: ncclRecv
// CHECK-NEXT: ncclReduce
// CHECK-NEXT: ncclReduceScatter
// CHECK-NEXT: ncclSend
// CHECK-NEXT: nearbyint
// CHECK-NEXT: nearbyintf
// CHECK-NEXT: nextafter
Expand Down
Loading

0 comments on commit c7f3594

Please sign in to comment.