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

fix: Handle mixed string casting that plagues optix codegen #1718

Merged
merged 2 commits into from
Aug 24, 2023

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Aug 23, 2023

The string situation is still a bit tricky on the OptiX side. There's a full overhaul of that coming separately as we continue to shift to an all-ustringhash world.

But in the mean time, we were getting some testsuite failures that were because of a mismatch between times we think of a gpu-side ustring as a char* and when it's a uint64. IN FACT, they are always the hashes, but we backed ourselves into a corner where sometimes that 64 bit pattern is passed around as a pointer, ugh.

This small patch attempts to catch this case and just do the appropriate cast to compensate. It's a band-aid; a more comprehensive fix is coming, as I said.

This gets us down to just ONE failing optix test case, which I will tackle separately.

The change necessitated adding a new ptr_to_int64_cast() method to LLVM_Util.

The string situation is still a bit tricky on the OptiX side.  There's
a full overhaul of that coming separately as we continue to shift to
an all-ustringhash world.

But in the mean time, we were getting some testsuite failures that
were because of a mismatch between times we think of a gpu-side
ustring as a char* and when it's a uint64. IN FACT, they are always
the hashes, but we backed ourselves into a corner where sometimes that
64 bit pattern is passed around as a pointer, ugh.

This small patch attempts to catch this case and just do the
appropriate cast to compensate. It's a band-aid, a more comprehensive
fix is coming, as I said.

This gets us down to just ONE filing optix test case, which I will
tackle separately.

Signed-off-by: Larry Gritz <[email protected]>
@lgritz lgritz requested a review from AlexMWells August 23, 2023 00:56
@@ -5216,6 +5224,7 @@ LLVM_Util::op_store(llvm::Value* val, llvm::Value* ptr)
std::cerr << "op_store val->getType()=" << std::flush;
val->getType()->print(llvm::errs());
std::cerr << std::endl;
// OSL_ASSERT(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented out line(?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to leave that for now to make it easy to add an assertion at that spot if it's triggered again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wait, maybe I'll change it to DASSERT.

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 my point was that it was currently commented out, so doing nothing.
Having it OSL_ASSERT or OSL_ASSERT is useful when in debugger because you get the builtin_trap and break right there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Commented out DOES SOMETHING -- it reminds me exactly where to put the assertion next time I have to track down another instance of the problem, and a single keystroke will activate it, but in the mean time it won't produce any extra error messages or stop a running program.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to not-commented-out OSL_DASSERT, so it will hit the assertion in debug mode, but not for production builds.

Copy link
Contributor

@AlexMWells AlexMWells left a comment

Choose a reason for hiding this comment

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

LGTM

@lgritz lgritz merged commit a4e779c into AcademySoftwareFoundation:main Aug 24, 2023
20 of 22 checks passed
@tgrant-nv tgrant-nv mentioned this pull request Aug 24, 2023
5 tasks
@lgritz lgritz deleted the lg-journal-fix branch September 4, 2023 00:41
chellmuth pushed a commit to chellmuth/OpenShadingLanguage that referenced this pull request Sep 6, 2024
  * build(deps): Raise minimum CMake dependency from 3.12 to 3.15 (AcademySoftwareFoundation#1724)
  * Change RendererServices::get_texture_handle back to ustring (AcademySoftwareFoundation#1726)
  * The recently added SS::find_symloc can have const args (AcademySoftwareFoundation#1723)
  * perf(gpu): Move qualifying GroupData params onto stack (AcademySoftwareFoundation#1710)
  * OptiX PTX pipeline overhaul (AcademySoftwareFoundation#1680)
  * Fix default fmt logic changing in latest openimageio release (AcademySoftwareFoundation#1725)
  * feat: Add API for building attribute getter free functions. (AcademySoftwareFoundation#1704)
  * fix: Handle mixed string casting that plagues optix codegen (AcademySoftwareFoundation#1718)
  * Rs fmt specification - Journaling Algorithm for error, warning, fprintf (AcademySoftwareFoundation#1702)
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.

2 participants