Skip to content

kwave can produce erroneous output on mac #339

Description

@ebrahimebrahim

This was discovered in #259 while debugging the failure of test_run_simulation_runs on mac only.


We've looked at the macos overflow issue and narrowed it down to the kwave binary doing different things on different systems.

In all cases, the input file that gets delivered into the kwave binary looks like this (this is a print so arrays can get elided, but hopefully enough of the idea is there to understand):

input to kwave
Nt [[[3]]]
Nx [[[81]]]
Ny [[[81]]]
Nz [[[81]]]
absorbing_flag [[[1]]]
alpha_coeff [[[0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  ...
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]]

 [[0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  ...
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]]

 [[0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  ...
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]]

 ...

 [[0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  ...
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]]

 [[0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  ...
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]]

 [[0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  ...
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]
  [0. 0. 0. ... 0. 0. 0.]]]
alpha_power [[[0.9]]]
axisymmetric_flag [[[0]]]
c0 [[[1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  ...
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]]

 [[1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  ...
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]]

 [[1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  ...
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]]

 ...

 [[1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  ...
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]]

 [[1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  ...
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]]

 [[1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  ...
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]
  [1500. 1500. 1500. ... 1500. 1500. 1500.]]]
c_ref [[[1500.]]]
dt [[[2.e-07]]]
dx [[[0.001]]]
dy [[[0.001]]]
dz [[[0.001]]]
elastic_flag [[[0]]]
nonlinear_flag [[[0]]]
nonuniform_grid_flag [[[0]]]
p0_source_flag [[[0]]]
p_source_flag [[[63]]]
p_source_index [[[238657 238658 238659 238660 238661 238662 238663 238664 238665 238666
   238667 238668 238669 238670 238671 238672 238673 238674 238675 238676
   238677 238738 238739 238740 238741 238742 238743 238744 238745 238746
   238747 238748 238749 238750 238751 238752 238753 238754 238755 238756
   238757 238758 238819 238820 238821 238822 238823 238824 238825 238826
   238827 238828 238829 238830 238831 238832 238833 238834 238835 238836
   238837 238838 238839 238900 238901 238902 238903 238904 238905 238906
   238907 238908 238909 238910 238911 238912 238913 238914 238915 238916
   238917 238918 238919 238920 238981 238982 238983 238984 238985 238986
   238987 238988 238989 238990 238991 238992 238993 238994 238995 238996
   238997 238998 238999 239000 239001 239062 239063 239064 239065 239066
   239067 239068 239069 239070 239071 239072 239073 239074 239075 239076
   239077 239078 239079 239080 239081 239082 239143 239144 239145 239146
   239147 239148 239149 239150 239151 239152 239153 239154 239155 239156
   239157 239158 239159 239160 239161 239162 239163 239224 239225 239226
   239227 239228 239229 239230 239231 239232 239233 239234 239235 239236
   239237 239238 239239 239240 239241 239242 239243 239244 239305 239306
   239307 239308 239309 239310 239311 239312 239313 239314 239315 239316
   239317 239318 239319 239320 239321 239322 239323 239324 239325 239386
   239387 239388 239389 239390 239391 239392 239393 239394 239395 239396
   239397 239398 239399 239400 239401 239402 239403 239404 239405 239406
   239467 239468 239469 239470 239471 239472 239473 239474 239475 239476
   239477 239478 239479 239480 239481 239482 239483 239484 239485 239486
   239487 239548 239549 239550 239551 239552 239553 239554 239555 239556
   239557 239558 239559 239560 239561 239562 239563 239564 239565 239566
   239567 239568 239629 239630 239631 239632 239633 239634 239635 239636
   239637 239638 239639 239640 239641 239642 239643 239644 239645 239646
   239647 239648 239649 239710 239711 239712 239713 239714 239715 239716
   239717 239718 239719 239720 239721 239722 239723 239724 239725 239726
   239727 239728 239729 239730 239791 239792 239793 239794 239795 239796
   239797 239798 239799 239800 239801 239802 239803 239804 239805 239806
   239807 239808 239809 239810 239811 239872 239873 239874 239875 239876
   239877 239878 239879 239880 239881 239882 239883 239884 239885 239886
   239887 239888 239889 239890 239891 239892 239953 239954 239955 239956
   239957 239958 239959 239960 239961 239962 239963 239964 239965 239966
   239967 239968 239969 239970 239971 239972 239973 240034 240035 240036
   240037 240038 240039 240040 240041 240042 240043 240044 240045 240046
   240047 240048 240049 240050 240051 240052 240053 240054 240115 240116
   240117 240118 240119 240120 240121 240122 240123 240124 240125 240126
   240127 240128 240129 240130 240131 240132 240133 240134 240135 240196
   240197 240198 240199 240200 240201 240202 240203 240204 240205 240206
   240207 240208 240209 240210 240211 240212 240213 240214 240215 240216
   240277 240278 240279 240280 240281 240282 240283 240284 240285 240286
   240287 240288 240289 240290 240291 240292 240293 240294 240295 240296
   240297]]]
p_source_input [[[ 0.0000000e+00  0.0000000e+00  0.0000000e+00 ...  0.0000000e+00
    0.0000000e+00  0.0000000e+00]
  [ 4.7698427e-07 -5.4399959e-07  1.2630575e-06 ...  1.2630575e-06
   -5.4399953e-07  4.7698416e-07]
  [ 8.3596893e-07 -9.5342102e-07  2.2136514e-06 ...  2.2136514e-06
   -9.5342074e-07  8.3596871e-07]
  ...
  [-9.4164091e-07  1.0739396e-06 -2.4934714e-06 ... -2.4934714e-06
    1.0739394e-06 -9.4164062e-07]
  [-6.7777000e-07  7.7299541e-07 -1.7947394e-06 ... -1.7947394e-06
    7.7299524e-07 -6.7776983e-07]
  [-2.4622784e-07  2.8082235e-07 -6.5201289e-07 ... -6.5201289e-07
    2.8082229e-07 -2.4622776e-07]]]
p_source_many [[[1]]]
p_source_mode [[[2]]]
pml_x_alpha [[[2.]]]
pml_x_size [[[30]]]
pml_y_alpha [[[2.]]]
pml_y_size [[[30]]]
pml_z_alpha [[[2.]]]
pml_z_size [[[34]]]
rho0 

However the outputs are different on my linux system versus Andrew's mac system. Linux:

output from kwave (linux)
Nt [[[3]]]
Nx [[[81]]]
Ny [[[81]]]
Nz [[[81]]]
absorbing_flag [[[1]]]
axisymmetric_flag [[[0]]]
c_ref [[[1500.]]]
dt [[[2.e-07]]]
dx [[[0.001]]]
dy [[[0.001]]]
dz [[[0.001]]]
nonlinear_flag [[[0]]]
nonuniform_grid_flag [[[0]]]
p0_source_flag [[[0]]]
p_max [[[0.         0.10062483 0.         ... 0.         0.00369736 0.        ]]]
p_min [[[-0.10217476  0.         -0.266634   ... -0.00996832  0.
   -0.0038342 ]]]
p_source_flag [[[63]]]
p_source_many [[[1]]]
p_source_mode [[[2]]]
pml_x_alpha [[[2.]]]
pml_x_size [[[30]]]
pml_y_alpha [[[2.]]]
pml_y_size [[[30]]]
pml_z_alpha [[[2.]]]
pml_z_size [[[34]]]
t_index [[[3]]]
transducer_source_flag [[[0]]]
ux_source_flag [[[0]]]
uy_source_flag [[[0]]]
uz_source_flag [[[0]]]

Mac:

output from kwave (mac)
Nt [[[3]]]
Nx [[[81]]]
Ny [[[81]]]
Nz [[[81]]]
absorbing_flag [[[1]]]
axisymmetric_flag [[[0]]]
c_ref [[[1500.]]]
dt [[[2.e-07]]]
dx [[[0.001]]]
dy [[[0.001]]]
dz [[[0.001]]]
nonlinear_flag [[[0]]]
nonuniform_grid_flag [[[0]]]
p0_source_flag [[[0]]]
p_max [[[-3.4028235e+38 -3.4028235e+38 -3.4028235e+38 ... -3.4028235e+38
   -3.4028235e+38 -3.4028235e+38]]]
p_min [[[3.4028235e+38 3.4028235e+38 3.4028235e+38 ... 3.4028235e+38
   3.4028235e+38 3.4028235e+38]]]
p_source_flag [[[63]]]
p_source_many [[[1]]]
p_source_mode [[[2]]]
pml_x_alpha [[[2.]]]
pml_x_size [[[30]]]
pml_y_alpha [[[2.]]]
pml_y_size [[[30]]]
pml_z_alpha [[[2.]]]
pml_z_size [[[34]]]
t_index [[[3]]]
transducer_source_flag [[[0]]]
ux_source_flag [[[0]]]
uy_source_flag [[[0]]]
uz_source_flag [[[0]]]

So exactly the same input to the binary, but two different outputs. You can see the unreasonable values for p_max and p_min in the mac output.

We tried a few things like adding more time steps and pushing the target out further, but we still get the overflow on mac.

Originally posted by @ebrahimebrahim in #259 (comment)


Traceability Information:

This information was populated automatically by a script on 2025-06-17T19:22:07Z.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions