Skip to content

[SYCLomatic] Refine the migration of 2 occupancy API migration #2882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: SYCLomatic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions clang/lib/DPCT/RulesLang/APINamesMisc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ CONDITIONAL_FACTORY_ENTRY(
CALL(MapNames::getDpctNamespace() +
"experimental::calculate_max_active_wg_per_xecore",
ARG(0), ARG(2),
BO(BinaryOperatorKind::BO_Add, ARG(3),
ARG("dpct_placeholder /* total share local memory "
"size */"))))),
makeCombinedArg(ARG(3),
ARG(" /* + dpct_placeholder (replace "
"dpct_placeholder with static "
"share local memory size) */"))))),
Diagnostics::MAX_ACTIVE_WG_ARGS,
ARG(MapNames::getDpctNamespace() +
"experimental::calculate_max_active_wg_per_xecore"),
Expand All @@ -38,9 +39,10 @@ CONDITIONAL_FACTORY_ENTRY(
CALL(MapNames::getDpctNamespace() +
"experimental::calculate_max_active_wg_per_xecore",
ARG(0), ARG(2),
BO(BinaryOperatorKind::BO_Add, ARG(3),
ARG("dpct_placeholder /* total share local memory "
"size */"))))),
makeCombinedArg(ARG(3),
ARG(" /* + dpct_placeholder (replace "
"dpct_placeholder with static "
"share local memory size) */"))))),
Diagnostics::MAX_ACTIVE_WG_ARGS,
ARG(MapNames::getDpctNamespace() +
"experimental::calculate_max_active_wg_per_xecore"),
Expand All @@ -59,26 +61,29 @@ CONDITIONAL_FACTORY_ENTRY(
CALL(MapNames::getDpctNamespace() +
"experimental::calculate_max_potential_wg",
ARG(0), ARG(1), ARG(4),
BO(BinaryOperatorKind::BO_Add, ARG(3),
ARG("dpct_placeholder /* total share local memory "
"size */")))),
makeCombinedArg(ARG(3),
ARG(" /* + dpct_placeholder (replace "
"dpct_placeholder with static "
"share local memory size) */")))),
CONDITIONAL_FACTORY_ENTRY(
CheckArgCount(4, std::equal_to<>(), false),
CALL_FACTORY_ENTRY(
"cudaOccupancyMaxPotentialBlockSize",
CALL(MapNames::getDpctNamespace() +
"experimental::calculate_max_potential_wg",
ARG(0), ARG(1), ARG("0"),
BO(BinaryOperatorKind::BO_Add, ARG(3),
ARG("dpct_placeholder /* total share local memory "
"size */")))),
makeCombinedArg(ARG(3),
ARG(" /* + dpct_placeholder (replace "
"dpct_placeholder with static "
"share local memory size) */")))),
CALL_FACTORY_ENTRY(
"cudaOccupancyMaxPotentialBlockSize",
CALL(MapNames::getDpctNamespace() +
"experimental::calculate_max_potential_wg",
ARG(0), ARG(1), ARG("0"),
ARG("dpct_placeholder /* total share local memory "
"size */"))))),
ARG("/* dpct_placeholder (replace dpct_placeholder "
"with static share local memory "
"size) */"))))),
Diagnostics::MAX_ACTIVE_WG_ARGS,
ARG(MapNames::getDpctNamespace() +
"experimental::calculate_max_potential_wg"),
Expand Down
10 changes: 5 additions & 5 deletions clang/test/dpct/enable-all-experimental-features.cu
Original file line number Diff line number Diff line change
Expand Up @@ -241,32 +241,32 @@ int occupancy() {
// CHECK: /*
// CHECK: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_active_wg_per_xecore" base on the target function "k".
// CHECK: */
// CHECK: dpct::experimental::calculate_max_active_wg_per_xecore(&num_blocks, block_size, dynamic_shared_memory_size + dpct_placeholder /* total share local memory size */);
// CHECK: dpct::experimental::calculate_max_active_wg_per_xecore(&num_blocks, block_size, dynamic_shared_memory_size /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cudaOccupancyMaxActiveBlocksPerMultiprocessor(&num_blocks, k, block_size, dynamic_shared_memory_size);

CUfunction func;
// CHECK: /*
// CHECK: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_active_wg_per_xecore" base on the target function "func".
// CHECK: */
// CHECK: dpct::experimental::calculate_max_active_wg_per_xecore(&num_blocks, block_size, dynamic_shared_memory_size + dpct_placeholder /* total share local memory size */);
// CHECK: dpct::experimental::calculate_max_active_wg_per_xecore(&num_blocks, block_size, dynamic_shared_memory_size /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cuOccupancyMaxActiveBlocksPerMultiprocessor(&num_blocks, func, block_size, dynamic_shared_memory_size);

int min_grid_size;
int block_size_limit;
// CHECK: /*
// CHECK-NEXT: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_potential_wg" base on the target function "k".
// CHECK-NEXT: */
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, 0, dpct_placeholder /* total share local memory size */);
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, 0, /* dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, k);
// CHECK: /*
// CHECK-NEXT: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_potential_wg" base on the target function "k".
// CHECK-NEXT: */
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, 0, dynamic_shared_memory_size + dpct_placeholder /* total share local memory size */);
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, 0, dynamic_shared_memory_size /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, k, dynamic_shared_memory_size);
// CHECK: /*
// CHECK-NEXT: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_potential_wg" base on the target function "k".
// CHECK-NEXT: */
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, block_size_limit, dynamic_shared_memory_size + dpct_placeholder /* total share local memory size */);
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, block_size_limit, dynamic_shared_memory_size /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, k, dynamic_shared_memory_size, block_size_limit);
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions clang/test/dpct/occupancy_expr.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ int main() {
// CHECK: /*
// CHECK: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_active_wg_per_xecore" base on the target function "k".
// CHECK: */
// CHECK: dpct::experimental::calculate_max_active_wg_per_xecore(&num_blocks, block_size, dynamic_shared_memory_size + dpct_placeholder /* total share local memory size */);
// CHECK: dpct::experimental::calculate_max_active_wg_per_xecore(&num_blocks, block_size, dynamic_shared_memory_size /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cudaOccupancyMaxActiveBlocksPerMultiprocessor(&num_blocks, k, block_size, dynamic_shared_memory_size);

CUfunction func;
// CHECK: /*
// CHECK: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_active_wg_per_xecore" base on the target function "func".
// CHECK: */
// CHECK: dpct::experimental::calculate_max_active_wg_per_xecore(&num_blocks, block_size, dynamic_shared_memory_size + dpct_placeholder /* total share local memory size */);
// CHECK: dpct::experimental::calculate_max_active_wg_per_xecore(&num_blocks, block_size, dynamic_shared_memory_size /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cuOccupancyMaxActiveBlocksPerMultiprocessor(&num_blocks, func, block_size, dynamic_shared_memory_size);

int min_grid_size;
int block_size_limit;
// CHECK: /*
// CHECK-NEXT: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_potential_wg" base on the target function "k".
// CHECK-NEXT: */
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, 0, dpct_placeholder /* total share local memory size */);
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, 0, /* dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, k);
// CHECK: /*
// CHECK-NEXT: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_potential_wg" base on the target function "k".
// CHECK-NEXT: */
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, 0, dynamic_shared_memory_size + dpct_placeholder /* total share local memory size */);
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, 0, dynamic_shared_memory_size /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, k, dynamic_shared_memory_size);
// CHECK: /*
// CHECK-NEXT: DPCT1111:{{[0-9]+}}: Please verify the input arguments of "dpct::experimental::calculate_max_potential_wg" base on the target function "k".
// CHECK-NEXT: */
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, block_size_limit, dynamic_shared_memory_size + dpct_placeholder /* total share local memory size */);
// CHECK-NEXT:dpct::experimental::calculate_max_potential_wg(&min_grid_size, &block_size, block_size_limit, dynamic_shared_memory_size /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);
cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, k, dynamic_shared_memory_size, block_size_limit);
return 0;
}
2 changes: 1 addition & 1 deletion clang/test/dpct/query_api_mapping/Driver/test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
// CUOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: cuOccupancyMaxActiveBlocksPerMultiprocessor(pi /*int **/, f /*CUfunction*/,
// CUOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: i /*int*/, s /*size_t*/);
// CUOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: Is migrated to (with the option --use-experimental-features=occupancy-calculation):
// CUOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: dpct::experimental::calculate_max_active_wg_per_xecore(pi, i, s + dpct_placeholder /* total share local memory size */);
// CUOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: dpct::experimental::calculate_max_active_wg_per_xecore(pi, i, s /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);

/// Texture Reference Management [DEPRECATED]

Expand Down
2 changes: 1 addition & 1 deletion clang/test/dpct/query_api_mapping/Runtime/test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
// CUDAOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: cudaOccupancyMaxActiveBlocksPerMultiprocessor(
// CUDAOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: pi /*int **/, pFunc /*const void **/, i /*int*/, s /*size_t*/);
// CUDAOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: Is migrated to (with the option --use-experimental-features=occupancy-calculation):
// CUDAOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: dpct::experimental::calculate_max_active_wg_per_xecore(pi, i, s + dpct_placeholder /* total share local memory size */);
// CUDAOCCUPANCYMAXACTIVEBLOCKSPERMULTIPROCESSOR-NEXT: dpct::experimental::calculate_max_active_wg_per_xecore(pi, i, s /* + dpct_placeholder (replace dpct_placeholder with static share local memory size) */);

/// Memory Management [DEPRECATED]

Expand Down