find_cuda: revert breaking change#7282
Conversation
Summary of ChangesHello @charlesseizilles, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a regression introduced in a prior change by restoring the correct field name for CUDA SDK versions. The change ensures that the system accurately identifies and utilizes the CUDA SDK version, preventing potential build or configuration issues that arose from the previous breaking change. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively reverts a breaking change by consistently renaming the sdkver field to version within the CUDA detection logic and its usage. This change improves code clarity by distinguishing between the requested SDK version and the detected SDK version, and correctly restores the functionality that was previously broken.
| local cuda = get_config("cuda") | ||
| local cuda_sdk = find_cuda(cuda) | ||
| local cuda_sdkver = cuda_sdk and cuda_sdk.sdkver or "7.0" | ||
| local cuda_sdkver = cuda_sdk and cuda_sdk.version or "7.0" |
|
|
||
| -- get version | ||
| local sdkver = find_programver(path.join(bindir, "nvcc"), {parse = "release (%d+%.%d+),"}) | ||
| local version = find_programver(path.join(bindir, "nvcc"), {parse = "release (%d+%.%d+),"}) |
There was a problem hiding this comment.
Renaming the local variable from sdkver to version enhances readability by clearly indicating that this variable holds the detected version of the CUDA SDK, differentiating it from the sdkver argument which represents the requested version.
local version = find_programver(path.join(bindir, "nvcc"), {parse = "release (%d+%.%d+),"})
|
|
||
| -- get toolchains | ||
| return {sdkdir = sdkdir, bindir = bindir, sdkver = sdkver, linkdirs = linkdirs, includedirs = includedirs, msbuildextensionsdir = msbuildextensionsdir} | ||
| return {sdkdir = sdkdir, bindir = bindir, version = version, linkdirs = linkdirs, includedirs = includedirs, msbuildextensionsdir = msbuildextensionsdir} |
There was a problem hiding this comment.
Updating the returned table field from sdkver = sdkver to version = version provides better semantic clarity. It explicitly states that the returned value is the detected version, aligning with the local variable name and improving the API's expressiveness.
return {sdkdir = sdkdir, bindir = bindir, version = version, linkdirs = linkdirs, includedirs = includedirs, msbuildextensionsdir = msbuildextensionsdir}
| -- save to config | ||
| config.set("cuda", cuda.sdkdir, {force = true, readonly = true}) | ||
| config.set("cuda_sdkver", cuda.sdkver, {force = true, readonly = true}) | ||
| config.set("cuda_sdkver", cuda.version, {force = true, readonly = true}) |
There was a problem hiding this comment.
The change from cuda.sdkver to cuda.version here correctly uses the updated field name from the find_cuda function's return value. This ensures that the detected CUDA version is saved to the configuration with the correct key, fixing the previous inconsistency.
config.set("cuda_sdkver", cuda.version, {force = true, readonly = true})
A breaking change was introduced in #6964
This PR fixes it