DPCT3001#

メッセージ#

“<CMake common command>” は、入力ファイルを変換して出力ファイルを生成するのに使用されます。入力ファイルに CUDA 構文が含まれている場合、入力と出力ファイルの名前を更新して入力ファイルを移行する場合もあります。

詳細な説明#

“<CMake common command>” は、入力ファイルを変換して出力ファイルを生成するのに使用されます。入力ファイルに CUDA 構文が含まれている場合、入力と出力ファイルの名前を更新して入力ファイルを移行する場合もあります。

修正方法の提案#

たとえば、“@ONLY” オプションを指定した CMake コマンド “configure_file(<input> <output> options)” は、<input> ファイル内の “@VAR@” 形式で明示的にマークされた変数 (サンプルコードの “@FOO_VERSION@” を参照) を、CMake スクリプトで定義された VAR の値 (CMake スクリプトの “FOO_VERSION” を参照) に置き換え、<output> ファイルとして保存します。

例えば、以下のオリジナル CUDA* コードについて考えてみます。

1  // src/bar.in.cu 
2  __global__ void hello_kernel() {} 
3 
4  int main() { 
5   std::cout << "FOO version: @FOO_VERSION@" << std::endl; 
6   hello_kernel<<<1, 1>>>(); 
7   cudaDeviceSynchronize(); 
8   return 0; 
9  }

元の CUDA* コードの CMake スクリプトは次のとおりです。

1  # src/CMakeLists.txt 
2  set(FOO_VERSION 1.00) 
3 
4  configure_file( 
5   ${CMAKE_SOURCE_DIR}/bar.in.cu 
6   ${CMAKE_BINARY_DIR}/bar.cu 
7   @ONLY 
8  )

このコードは、以下の SYCL* コードに移行されます。

1  // build/bar.dp.cpp 
2  void hello_kernel() { 
3  } 
4 
5  int main() { 
6   std::cout << "FOO version: 1.00" << std::endl; // 置き換え例 
7   dpct::get_in_order_queue().parallel_for( 
8   sycl::nd_range<3>(sycl::range<3>(1, 1, 1), sycl::range<3>(1, 1, 1)), 
9   [=](sycl::nd_item<3> item_ct1) { 
10  hello_kernel(); 
11  }); 
12  dpct::get_current_device().queues_wait_and_throw(); 
13  return 0; 
14 }
1  # CMakeLists.txt 
2  set(FOO_VERSION 1.00) 
3  DPCT3001:1: "configure_file" is used to generate an output file by performing 
4  transformation on input file.You may need to update the name of the input and 
5  output file, as well as migrate the input file if the input file contains CUDA syntax 
6  configure_file( 
7   ${CMAKE_SOURCE_DIR}/bar.in.dp.cpp 
8   ${CMAKE_BINARY_DIR}/bar.dp.cpp 
9   @ONLY 
10 )

上記は次のように書き換える必要があります。

1  // src/bar.in.dp.cpp 
2  void hello_kernel() { 
3  } 
4 
5  int main() { 
6   std::cout << "FOO version: @FOO_VERSION@" << std::endl; 
7   dpct::get_in_order_queue().parallel_for( 
8   sycl::nd_range<3>(sycl::range<3>(1, 1, 1), sycl::range<3>(1, 1, 1)), 
9   [=](sycl::nd_item<3> item_ct1) { 
10  hello_kernel(); 
11  }); 
12  dpct::get_current_device().queues_wait_and_throw(); 
13  return 0; 
14 }

および

1  # src/CMakeLists.txt 
2  set(FOO_VERSION 1.00) 
3  configure_file( 
4   ${CMAKE_SOURCE_DIR}/bar.in.dp.cpp 
5   ${CMAKE_BINARY_DIR}/bar.dp.cpp 
6   @ONLY 
7  )