Skip to content
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

Create a class registration file #234

Merged
merged 4 commits into from
Nov 10, 2022

Conversation

denizumuteser
Copy link
Collaborator

  • Updated instantiation generation script to read from common JSON file.
  • Added a common JSON file and moved all hardcoded class templates there.

@denizumuteser denizumuteser linked an issue Nov 8, 2022 that may be closed by this pull request
@denizumuteser denizumuteser marked this pull request as draft November 8, 2022 16:48
@denizumuteser denizumuteser marked this pull request as ready for review November 8, 2022 17:05
for each_class in class_instantiation_list:
#print(each_class)
#setting current filename
if current_filename != each_class.get("filename"):
Copy link
Contributor

@AmroAlJundi AmroAlJundi Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this mechanism requires the writers into class_instantiation_list.json to make sure they list out all the classes of a file sequentially It is a reasonable thing to ask of the developers, but if they don't do it accidentally, it will lead to weird linking errors.

I think a better approach is to store a dictionary of opened files and only reset a file the first time it is encountered.


#choosing folder
current_folder = each_class.get("folder")
if each_class.get("ifdef") == "USE_CUDA":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better, more generic, approach here is to repurpose the folder field in the JSON to actually store the name of the sub-folder to store the init files (the folder inside output_folder). So if it's null, store it in the default folder, and if it's not null, then store it in os.path.join(output_folder, each_class.get("folder")).

Copy link
Contributor

@AmroAlJundi AmroAlJundi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Just address the comments I left and I think it's good to go.

One thing we lose with this approach, though, is the ability to dynamically generate some of these template strings (like how loops were being used to generate template strings for the CsrCUDACsrConditionalFunction function and its likes). However, this JSON will hopefully be used to also generate other parts of the code (docs specifically) so I think the pros outweigh the cons.

@denizumuteser denizumuteser marked this pull request as draft November 9, 2022 20:56
@denizumuteser denizumuteser marked this pull request as ready for review November 9, 2022 21:47
@denizumuteser denizumuteser merged commit 88bd4b8 into develop Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a class registration file
2 participants