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

Rotate input photons #24

Merged
merged 5 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

This is a repeat of experiment_01, but with timing measurements for the calls to `generate_emitter_data(...)` (which converts "Geant4" photons into a `numpy` object that can be understood by Mitsuba3), and the call to `mi.VolumeGrid(...)` which takes the result of the generated data and creates a `VolumeGrid` Mitsuba3 code object that can then be placed into a Mitsuba3 scene.

The code changes required to do this are on a new branch, but not (yet) merged into `dev`, with the name `21-update-the-scripts-to-measure-time-to-generate-photon-lists`.

## Results

Results were obtained on both the CPUs and GPUs of the Noether HEP cluster, details of which can be found in experiment 01's write-up.
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Repeat experiment 04, but with rotations applied to initial data

## Background / Method

This is a repeat of experiment_04, but rather than repeating the initial photon data in order to run large numbers of photons, each repeat adds a small rotation to the initial photon data and then appends that to a set of data starting from the initial photon data. This was done in order to avoid repeated data / ray paths where possible, which may tell us whether Mitsuba / Dr.Jit are doing something clever when repeated data / ray paths are discovered prior or during the rendering step.

To rotate photon data, modify the script so that `rotate_photon_data = True`.

## Results

Results were obtained on both the CPUs and GPUs of the Noether HEP cluster, details of which can be found in experiment_01's write-up.

All timing PNGs and CSVs created for this experiment can be found in the `experiment_05` directory at the level of this file.

Averaged timing results for running `cuda_mono`, `cuda_rgb`, `llvm_mono` and `llvm_ad_rgb` variants are shown below.

![Timing results for llvm_mono](experiment_05/png/llvm_mono_timing_for_n_photons.png)
![Timing results for llvm_ad_rgb](experiment_05/png/llvm_ad_rgb_timing_for_n_photons.png)
![Timing results for cuda_mono](experiment_05/png/cuda_mono_timing_for_n_photons.png)
![Timing results for cuda_ad_rgb](experiment_05/png/cuda_ad_rgb_timing_for_n_photons.png)

Comparing the results for each step in Mitsuba3 across variants is shown below.

![Timing results for generate step](experiment_05/png/generate_timing_for_n_photons.png)
![Timing results for volume step](experiment_05/png/volume_timing_for_n_photons.png)
![Timing results for load step](experiment_05/png/load_timing_for_n_photons.png)
![Timing results for render step](experiment_05/png/render_timing_for_n_photons.png)
![Timing results for load and render steps](experiment_05/png/load_and_render_timing_for_n_photons.png)
![Timing results for full job run](experiment_05/png/full_time_timing_for_n_photons.png)

This does not appear to make any difference to the previous results observed in experiment 04.

However, I do note that there appears to be an observable slowdown in the render step in the LLVM variants (i.e. when using CPU). The largest value of n_photons here is chosen because it is close to the memory limits of the nodes available on the HEP Noether cluster; it seems to me that it will be worth investigating running this on the central CSF facility at the University of Manchester, where there are larger nodes available.

## Conclusions and future work

Some investigation of larger numbers of photons would appear to be required - this will likely require access to the CSF.
33 changes: 32 additions & 1 deletion MPhys/Single_Emitter/single_emitter_test_new_change_nphotons.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,38 @@
photon_detected_load = pd.read_csv('csv/test_new_photons_detected_spectral.csv', index_col=0) #, names = column_names)
# photon_detected_load.reset_index(drop=True, inplace=True)
# The number of photons actually in this file is somewhere just under 10^6
photon_detected = pd.concat([photon_detected_load for _ in range(n_repeats)], ignore_index=True)
# In order to test the theory that the render step is independent of the number of photons,
# rather than repeating the same data over again, add a small rotation to the data instead
# By default, don't do this
rotate_photon_data = False
photon_detected = None
if rotate_photon_data:
photons_detected = [photon_detected_load]

def rotate_xy(df, theta):
print(df.keys())
new_df = pd.DataFrame()
x = df["x"].copy()
y = df["y"].copy()
new_df["time (ps)"] = df["time (ps)"].copy()
new_df["x"] = x * np.cos(theta) - y * np.sin(theta)
new_df["y"] = y * np.cos(theta) + x * np.sin(theta)
new_df["z"] = df["z"].copy()
new_df["px"] = df["px"].copy()
new_df["py"] = df["py"].copy()
new_df["pz"] = df["pz"].copy()
new_df["Wavelength (nm)"] = df["Wavelength (nm)"].copy()
return new_df

for n in range(n_repeats):
# Rotate point and target by small amount, and add to photons_detected
photon_detected_rot = rotate_xy(photon_detected_load, (n+1)*0.1)
photons_detected.append(photon_detected_rot)

photon_detected = pd.concat(photons_detected, ignore_index=True)
else:
photon_detected = pd.concat([photon_detected_load for _ in range(n_repeats)], ignore_index=True)


print(photon_detected_load)
print(photon_detected)
Expand Down