Skip to content

Conversation

@leonhostetler
Copy link
Contributor

Adds a function writeGaugeQuda to lib/interface_quda.cpp. This function is similar to saveGaugeQuda but writes the gauge field to disk instead of just copying it to host.

The motivation for this is a desire to be able to write a gradient flowed gauge field (i.e. gaugeSmeared) to disk after using performWFlowQuda or performGFlowQuda, without going through the rigamarole of allocating space from MILC, copying the flowed field back to MILC, and then writing it to disk. This will also allow us to write the fat and long links to disk, which is something we've been working on as well.

@leonhostetler leonhostetler requested a review from a team as a code owner December 30, 2025 19:56
@weinbe2
Copy link
Contributor

weinbe2 commented Dec 30, 2025

Thanks for the PR, Leon, this looks good to me and is a good contribution. I had an idea to simplify this which should be a relatively quick copy+paste job.

You could create a null CPU field at the start of the function, and then within the switch statement you could call cpuField.copy(...); as appropriate for the gauge field/fat links/long links. The smeared links would of course need the intermediate copy to a non-extended field, but in that case all of the logic can stay local, and you can create a GaugeField as opposed to a pointer thereto.

I think this should all "just work", but let me know what you think.

@leonhostetler
Copy link
Contributor Author

@weinbe2 I have revised and retested. Let me know what you think. I think it is indeed better now with the logic for each case easier to follow and more self-contained/local.

@weinbe2
Copy link
Contributor

weinbe2 commented Jan 2, 2026

Thanks @leonhostetler , this is exactly what I was picturing. I left one comment on the code for a trivial change. Otherwise, I'll do a cursory due-diligence build (I expect no surprises) and give an approve once the change is in.

GaugeField cudaGauge(cuda_param);
copyExtendedGauge(cudaGauge, *gaugeSmeared, QUDA_CUDA_FIELD_LOCATION);
cpuGauge.copy(cudaGauge);
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this break; needs to be below the closing } on the following line, if anything as a "best practice". The case QUDA_SMEARED_LINKS: block will always hit the break; in this case so it should be legal, but it still feels a bit too weird to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I see what you mean. I have made the change.

Copy link
Contributor

@weinbe2 weinbe2 left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks @leonhostetler

@weinbe2 weinbe2 merged commit c4ac06b into develop Jan 5, 2026
7 of 8 checks passed
@weinbe2 weinbe2 deleted the feature/write-gauge branch January 5, 2026 19:52
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.

3 participants