Efficient processing of two-dimensional arrays with C or C++

Techniques and Methods 7-E1
By:

Links

Abstract

Because fast and efficient serial processing of raster-graphic images and other two-dimensional arrays is a requirement in land-change modeling and other applications, the effects of 10 factors on the runtimes for processing two-dimensional arrays with C and C++ are evaluated in a comparative factorial study. This study’s factors include the choice among three C or C++ source-code techniques for array processing; the choice of Microsoft Windows 7 or a Linux operating system; the choice of 4-byte or 8-byte array elements and indexes; and the choice of 32-bit or 64-bit memory addressing. This study demonstrates how programmer choices can reduce runtimes by 75 percent or more, even after compiler optimizations. Ten points of practical advice for faster processing of two-dimensional arrays are offered to C and C++ programmers. Further study and the development of a C and C++ software test suite are recommended.

Key words: array processing, C, C++, compiler, computational speed, land-change modeling, raster-graphic image, two-dimensional array, software efficiency

Suggested Citation

Donato, D.I., 2017, Efficient processing of two-dimensional arrays with C or C++: U.S. Geological Survey Techniques and Methods Report 7–E1, 58 pages, https://doi.org/10.3133/tm7E1.

ISSN: 2328-7055 (online)

Table of Contents

  • Acknowledgments
  • Abstract
  • Introduction
  • Understanding C and C++ Syntax for Two-Dimensional Arrays
  • Design of a Comparative Factorial Study of Runtimes
  • Analysis of the Results of the Comparative Study
  • Practical Advice for Software Developers
  • Conclusions and Recommendations
  • References Cited
  • Appendix 1. Scatter Diagrams
  • Appendix 2. Boxplots
  • Appendix 3. Source Code for C Test Programs
  • Appendix 4. Source Code for C++ Test Programs 
  • Appendix 5. Scripts and Code for Conducting Timing Tests on Linux
  • Appendix 6. Scripts and Code for Conducting Timing Tests on Windows
Publication type Report
Publication Subtype USGS Numbered Series
Title Efficient processing of two-dimensional arrays with C or C++
Series title Techniques and Methods
Series number 7-E1
DOI 10.3133/tm7E1
Year Published 2017
Language English
Publisher U.S. Geological Survey
Publisher location Reston, VA
Contributing office(s) Eastern Geographic Science Center
Description Report: ix, 58 p.; Appendixes; Data Release
Larger Work Type Report
Larger Work Subtype USGS Numbered Series
Larger Work Title Section E: Evaluating and Improving Computational Performance in Book 7: Automated Data Processing and Computations
Public Comments This report is Chapter 1 of Section E: Evaluating and Improving Computational Performance in Book 7: Automated Data Processing and Computations.
Online Only (Y/N) Y
Additional Online Files (Y/N) Y
Google Analytic Metrics Metrics page
Additional publication details