Skip to content

Commit f085cc9

Browse files
committed
GDALDataset::ComputeInterBandCovarianceMatrix(): optimize CPU usage
1 parent aba7d0f commit f085cc9

File tree

4 files changed

+459
-226
lines changed

4 files changed

+459
-226
lines changed

autotest/gcore/gdal_stats.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ def test_stats_ComputeInterBandCovarianceMatrix_nodata():
14591459
ds.GetRasterBand(2).WriteRaster(0, 0, 4, 1, b"\x02\x01\xFE\x03")
14601460
ds.GetRasterBand(2).SetNoDataValue(254)
14611461

1462-
expected_cov_matrix = [[1, -0.5], [-0.5, 1]]
1462+
expected_cov_matrix = [[1, 0], [0, 1]]
14631463

14641464
cov_matrix = ds.ComputeInterBandCovarianceMatrix()
14651465
assert list(chain.from_iterable(cov_matrix)) == pytest.approx(
@@ -1476,7 +1476,7 @@ def test_stats_ComputeInterBandCovarianceMatrix_nan_value():
14761476
ds.GetRasterBand(1).WriteRaster(0, 0, 4, 1, struct.pack("f" * 4, 1, 2, 3, math.nan))
14771477
ds.GetRasterBand(2).WriteRaster(0, 0, 4, 1, struct.pack("f" * 4, 2, 1, math.nan, 3))
14781478

1479-
expected_cov_matrix = [[1, -0.5], [-0.5, 1]]
1479+
expected_cov_matrix = [[1, 0], [0, 1]]
14801480

14811481
cov_matrix = ds.ComputeInterBandCovarianceMatrix()
14821482
assert list(chain.from_iterable(cov_matrix)) == pytest.approx(
@@ -1527,7 +1527,7 @@ def test_stats_ComputeInterBandCovarianceMatrix_mask_band():
15271527
ds.GetRasterBand(2).CreateMaskBand(0)
15281528
ds.GetRasterBand(2).GetMaskBand().WriteRaster(0, 0, 4, 1, b"\xFF\xFF\x00\xFF")
15291529

1530-
expected_cov_matrix = [[1, -0.5], [-0.5, 1]]
1530+
expected_cov_matrix = [[1, 0], [0, 1]]
15311531

15321532
cov_matrix = ds.ComputeInterBandCovarianceMatrix()
15331533
assert list(chain.from_iterable(cov_matrix)) == pytest.approx(

gcore/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows")
212212
gdal_target_link_libraries(gcore PRIVATE psapi)
213213
endif ()
214214

215+
if (HAVE_OPENMP_SIMD)
216+
target_compile_definitions(gcore PRIVATE HAVE_OPENMP_SIMD)
217+
endif()
218+
215219
include(TargetPublicHeader)
216220
target_public_header(
217221
TARGET

0 commit comments

Comments
 (0)