From 97a949c12198b97d6131c1db2b392beb4e50bd9d Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 17 Jan 2025 22:01:20 +0100 Subject: [PATCH] [HIPIFY][perl] Minor formatting changes in the `hipify-perl` code generation --- bin/hipify-perl | 8 ++++---- src/CUDA2HIP_Perl.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/hipify-perl b/bin/hipify-perl index 5e441a85..ef5c4cc7 100755 --- a/bin/hipify-perl +++ b/bin/hipify-perl @@ -9602,7 +9602,7 @@ sub transformHostFunctions { "__all_sync", "__all", "__activemask" - ); +); sub countSupportedDeviceFunctions { my $k = 0; @@ -9872,7 +9872,7 @@ sub countSupportedDeviceFunctions { "__bfloat162int_rd", "__bfloat162char_rz", "_Pow_int" - ); +); sub warnUnsupportedDeviceFunctions { my $line_num = shift; @@ -9916,7 +9916,7 @@ sub warnUnsupportedDeviceFunctions { "__NV_NOSAT", "__NV_E5M2", "__NV_E4M3" - ); +); sub countSupportedDeviceDataTypes { my $k = 0; @@ -9932,7 +9932,7 @@ sub countSupportedDeviceDataTypes { @UnsupportedDeviceDataTypes = ( "nv_bfloat162" - ); +); sub warnUnsupportedDeviceDataTypes { my $line_num = shift; diff --git a/src/CUDA2HIP_Perl.cpp b/src/CUDA2HIP_Perl.cpp index d2e48750..1b3a93af 100644 --- a/src/CUDA2HIP_Perl.cpp +++ b/src/CUDA2HIP_Perl.cpp @@ -485,7 +485,7 @@ namespace perl { *streamPtr.get() << tab << s_k << "<<<\\s*([^,\\(\\)]+|[\\w\\s:]*\\([\\w|\\s|,|:|\\+|\\*|\\-|\\/|(?R)]+\\))\\s*,\\s*([^,\\(\\)]+|[\\w\\s:]*\\([\\w|\\s|,|:|\\+|\\*|\\-|\\/|(?R)]+\\))\\s*>>>\\s*\\(/hipLaunchKernelGGL($1, $2, $3, 0, 0, /g;" << endl_2; *streamPtr.get() << tab << "if ($k) {" << endl; - *streamPtr.get() << tab_2 << "$ft{'kernel_launch'} += $k;" << endl; + *streamPtr.get() << tab_2 << "$ft{'" << counterNames[CONV_KERNEL_LAUNCH] << "'} += $k;" << endl; *streamPtr.get() << tab_2 << "$Tkernels{$1}++;" << endl_tab << "}" << endl << "}" << endl; } @@ -734,10 +734,10 @@ namespace perl { subCountSupportedDataTypes << endl << sub << sCountSupportedDeviceDataTypes << " {" << endl << (countSupportedDataTypes ? sCommon + sSupportedDeviceDataTypes + ")\n" : tab + return_0); subWarnUnsupported << endl << sub << sWarnUnsupportedDeviceFunctions << " {" << endl << (countUnsupported ? tab + my + "$line_num = shift;\n" + sCommon + sUnsupportedDeviceFunctions + ")\n" : tab + return_0); subWarnUnsupportedDataTypes << endl << sub << sWarnUnsupportedDeviceDataTypes << " {" << endl << (countUnsupportedDataTypes ? tab + my + "$line_num = shift;\n" + sCommon + sUnsupportedDeviceDataTypes + ")\n" : tab + return_0); - if (countSupported) supported << sSupported.str() << endl_tab << ");" << endl; - if (countSupportedDataTypes) supportedDataTypes << sSupportedDataTypes.str() << endl_tab << ");" << endl; - if (countUnsupported) unsupported << sUnsupported.str() << endl_tab << ");" << endl; - if (countUnsupportedDataTypes) unsupportedDataTypes << sUnsupportedDataTypes.str() << endl_tab << ");" << endl; + if (countSupported) supported << sSupported.str() << endl << ");" << endl; + if (countSupportedDataTypes) supportedDataTypes << sSupportedDataTypes.str() << endl << ");" << endl; + if (countUnsupported) unsupported << sUnsupported.str() << endl << ");" << endl; + if (countUnsupportedDataTypes) unsupportedDataTypes << sUnsupportedDataTypes.str() << endl << ");" << endl; if (countSupported || countUnsupported) { subCommon << tab << "{" << endl; subCommon << tab_2 << "# match device function from the list, except those, which have a namespace prefix (aka somenamespace::umin(...));" << endl; @@ -932,7 +932,7 @@ namespace perl { *streamPtr.get() << tab_4 << sTransformKernelLaunch << "();" << endl; *streamPtr.get() << tab_3 << "}" << endl; *streamPtr.get() << tab_3 << sTransformCubNamespace << "();" << endl; - *streamPtr.get() << tab_3 << my << "$hasDeviceCode = $countKeywords + $ft{'device_function'} + $ft{'device_type'};" << endl; + *streamPtr.get() << tab_3 << my << "$hasDeviceCode = $countKeywords + $ft{'" << counterNames[CONV_DEVICE_FUNC] << "'} + $ft{'" << counterNames[CONV_DEVICE_TYPE] << "'};" << endl; *streamPtr.get() << tab_3 << unless_ << "($quiet_warnings) {" << endl; *streamPtr.get() << tab_4 << "# Copy into array of lines, process line-by-line to show warnings" << endl; *streamPtr.get() << tab_4 << "if ($hasDeviceCode or (/\\bcu|CU/) or (/<<<.*>>>/)) {" << endl; @@ -955,8 +955,8 @@ namespace perl { *streamPtr.get() << tab_7 << print << "\" warning: $fileName:#$line_num : $_\\n\";" << endl_tab_6 << "}" << endl_tab_5 << "}" << endl; *streamPtr.get() << tab_5 << "$_ = $tmp;" << endl_tab_4 << "}" << endl_tab_3 << "}" << endl; *streamPtr.get() << tab_3 << "if ($hasDeviceCode > 0) {" << endl; - *streamPtr.get() << tab_4 << "$ft{'device_function'} += " << sCountSupportedDeviceFunctions << "();" << endl; - *streamPtr.get() << tab_4 << "$ft{'device_type'} += " << sCountSupportedDeviceDataTypes << "();" << endl_tab_3 << "}" << endl; + *streamPtr.get() << tab_4 << "$ft{'" << counterNames[CONV_DEVICE_FUNC] << "'} += " << sCountSupportedDeviceFunctions << "();" << endl; + *streamPtr.get() << tab_4 << "$ft{'" << counterNames[CONV_DEVICE_TYPE] << "'} += " << sCountSupportedDeviceDataTypes << "();" << endl_tab_3 << "}" << endl; *streamPtr.get() << tab_3 << "transformHostFunctions();" << endl; *streamPtr.get() << tab_3 << "# TODO: would like to move this code outside loop but it uses $_ which contains the whole file" << endl; *streamPtr.get() << tab_3 << unless_ << "($no_output) {" << endl;