-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Implement edmTypeInfo
#50842
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
Merged
Merged
Implement edmTypeInfo
#50842
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #! /bin/bash -e | ||
| # | ||
| # Run `edmTypeInfo` and compare its output against the expected results. | ||
|
|
||
| function can_run() { | ||
| local CMD="$1" | ||
|
|
||
| OUTPUT=$(${CMD}) | ||
| } | ||
|
|
||
| function compare() { | ||
| local CMD="$1" | ||
| local EXPECTED="$2" | ||
| local OUTPUT | ||
| OUTPUT=$(${CMD}) | ||
|
|
||
| if [ "${OUTPUT}" != "${EXPECTED}" ]; then | ||
| echo "Error: unexpected output" | ||
| echo "Command:" | ||
| echo "${CMD}" | ||
| echo | ||
| echo "Expected output:" | ||
| echo "${EXPECTED}" | ||
| echo | ||
| echo "Actual output:" | ||
| echo "${OUTPUT}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
|
|
||
| # Run edmTypeInfo portabletest::TestHostCollection | ||
| CMD="edmTypeInfo portabletest::TestHostCollection" | ||
| EXPECTED='`portabletest::TestHostCollection` resolves to `PortableHostCollection<portabletest::TestSoALayout<128,false> >` | ||
| with friendly class name `128falseportabletestTestSoALayoutPortableHostCollection` | ||
| with type info `22PortableHostCollectionIN12portabletest13TestSoALayoutILm128ELb0EEEE`' | ||
| compare "${CMD}" "${EXPECTED}" | ||
|
|
||
| # Run edmTypeInfo ALPAKA_ACCELERATOR_NAMESPACE::portabletest::TestDeviceCollection | ||
| CMD="edmTypeInfo ALPAKA_ACCELERATOR_NAMESPACE::portabletest::TestDeviceCollection" | ||
| EXPECTED='`alpaka_serial_sync::portabletest::TestDeviceCollection` does not resolve to any type known to ROOT | ||
|
|
||
| `alpaka_cuda_async::portabletest::TestDeviceCollection` resolves to `PortableDeviceCollection<alpaka::DevUniformCudaHipRt<alpaka::ApiCudaRt>,portabletest::TestSoALayout<128,false>,void>` | ||
| with friendly class name `alpakaDevCudaRt128falseportabletestTestSoALayoutvoidPortableDeviceCollection` | ||
| with type info `24PortableDeviceCollectionIN6alpaka19DevUniformCudaHipRtINS0_9ApiCudaRtEEEN12portabletest13TestSoALayoutILm128ELb0EEEvE` | ||
|
|
||
| `alpaka_rocm_async::portabletest::TestDeviceCollection` resolves to `PortableDeviceCollection<alpaka::DevUniformCudaHipRt<alpaka::ApiHipRt>,portabletest::TestSoALayout<128,false>,void>` | ||
| with friendly class name `alpakaDevHipRt128falseportabletestTestSoALayoutvoidPortableDeviceCollection` | ||
| with type info `24PortableDeviceCollectionIN6alpaka19DevUniformCudaHipRtINS0_8ApiHipRtEEEN12portabletest13TestSoALayoutILm128ELb0EEEvE`' | ||
| compare "${CMD}" "${EXPECTED}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #! /usr/bin/env python3 | ||
|
|
||
| import os | ||
| import sys | ||
| import ROOT | ||
|
|
||
| ROOT.gSystem.Load("libFWCoreReflection.so") | ||
| ROOT.gInterpreter.Declare('#include "FWCore/Reflection/interface/TypeWithDict.h"') | ||
|
|
||
| def usage(name): | ||
| print(f"""Usage: edmTypeInfo [options] [types] | ||
| Resolve C++ types to the full C++ type name, friendly class name, and mangled name. | ||
|
|
||
| Options: | ||
| -h, --help display this help and exit | ||
| -v, --version print version information and exit | ||
|
|
||
|
|
||
| Resolve each C++ type name in "types" to its actual definition based on its ROOT dictionary, taking into account type aliases and the use of ALPAKA_ACCELERATOR_NAMESPACE. | ||
| For each type print the full c++ name, the friendly class name, and the mangled name. | ||
| """) | ||
|
|
||
|
|
||
| def version(name): | ||
| print('edmTypeInfo : %s' % os.environ.get('CMSSW_VERSION')) | ||
|
|
||
| def resolve(name): | ||
| type = ROOT.edm.TypeWithDict.byName(name) | ||
| if (type): | ||
| print(f'`{name}` resolves to `{type.name()}`') | ||
| print(f' with friendly class name `{type.friendlyClassName()}`') | ||
| print(f' with type info `{type.typeInfo().name()}`') | ||
| else: | ||
| print(f'`{name}` does not resolve to any type known to ROOT') | ||
| print() | ||
|
|
||
|
|
||
| if '-h' in sys.argv[1:] or '--help' in sys.argv[1:]: | ||
| usage(sys.argv[0]) | ||
| sys.exit(0) | ||
|
|
||
| if '-v' in sys.argv[1:] or '--version' in sys.argv[1:]: | ||
| version(sys.argv[0]) | ||
| sys.exit(0) | ||
|
|
||
| for name in sys.argv[1:]: | ||
|
fwyzard marked this conversation as resolved.
|
||
| if 'ALPAKA_ACCELERATOR_NAMESPACE' in name: | ||
| for ns in 'alpaka_serial_sync', 'alpaka_cuda_async', 'alpaka_rocm_async': | ||
| ns_name = name.replace('ALPAKA_ACCELERATOR_NAMESPACE', ns) | ||
| resolve(ns_name) | ||
| else: | ||
| resolve(name) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #! /bin/bash -e | ||
| # | ||
| # Run `edmTypeInfo` and compare its output against the expected results. | ||
|
|
||
| function can_run() { | ||
| local CMD="$1" | ||
|
|
||
| OUTPUT=$(${CMD}) | ||
| } | ||
|
|
||
| function compare() { | ||
| local CMD="$1" | ||
| local EXPECTED="$2" | ||
| local OUTPUT | ||
| OUTPUT=$(${CMD}) | ||
|
|
||
| if [ "${OUTPUT}" != "${EXPECTED}" ]; then | ||
| echo "Error: unexpected output" | ||
| echo "Command:" | ||
| echo "${CMD}" | ||
| echo | ||
| echo "Expected output:" | ||
| echo "${EXPECTED}" | ||
| echo | ||
| echo "Actual output:" | ||
| echo "${OUTPUT}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
|
|
||
| # Run edmTypeInfo -h | ||
| CMD="edmTypeInfo -h" | ||
| can_run "${CMD}" | ||
|
|
||
| # Run edmTypeInfo -v | ||
| CMD="edmTypeInfo -v" | ||
| can_run "${CMD}" | ||
|
|
||
| # Run edmTypeInfo edmtest::reflection::IntObject | ||
| CMD="edmTypeInfo edmtest::reflection::IntObject" | ||
| EXPECTED='`edmtest::reflection::IntObject` resolves to `edmtest::reflection::IntObject` | ||
| with friendly class name `edmtestreflectionIntObject` | ||
| with type info `N7edmtest10reflection9IntObjectE`' | ||
| compare "${CMD}" "${EXPECTED}" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.