encyclopegia.org

Privatization (computer programming)

Privatization is a technique used in shared-memory programming to enable parallelism, by removing dependencies that occur across different threads in a parallel program. Dependencies between threads arise from two or more threads reading or writing a variable at the same time. Privatization gives each thread a private copy, so it can read and write it independently and thus, simultaneously. Each parallel algorithm specifies whether a variable is shared or private. Many errors in implementation can arise if the variable is declared to be shared but the algorithm requires it to be private, or vice versa. Traditionally, parallelizing compilers could apply privatization to scalar elements only. To exploit parallelism that occurs across iterations within a parallel program (loop-level parallelism), the need grew for compilers that can also perform array variable privatization. Most of today's compilers can performing array privatization with more features and functions to enhance the performance of the parallel program in general. An example is the Polaris parallelizing compiler.

Privatization is a technique used in shared-memory programming to enable parallelism, by removing dependencies that occur across different threads in a parallel program. Dependencies between threads arise from two or more threads reading or writing a variable at the same time. Privatization gives each thread a private copy, so it can read and write it independently and thus, simultaneously. Each parallel algorithm specifies whether a variable is shared or private. Many errors in implementation can arise if the variable is declared to be shared but the algorithm requires it to be private, or vice versa. Traditionally, parallelizing compilers could apply privatization to scalar elements only. To exploit parallelism that occurs across iterations within a parallel program (loop-level parallelism), the need grew for compilers that can also perform array variable privatization. Most of today's compilers can performing array privatization with more features and functions to enhance the performance of the parallel program in general. An example is the Polaris parallelizing compiler. === Variable scope === The next step in the model groups tasks together into bigger tasks, as there are typically more tasks than available processors. Typically, the number of execution threads that the tasks are assigned to, is chosen to be less than or equal to the number of processors, with each thread assigned to a unique processor. Right after this step, the use of variables within tasks needs to be analyzed. This step determines whether each variable should be shared-by-all or private-to-each thread. This step is unique to shared-memory programming. (An alternative is message passing, in which all variables are private.) According to their behavior, the variables are then categorized as: Read-Only: when a variable is only read by all the parallel tasks. Read/Write Non-conflicting: when a variable is read, written, or both by only one task. If the variable is not scalar, different elements may be read/written by different parallel tasks. Read/Write Conflicting: when a variable is written by a task and may be read by another. If the variable is not scalar, different elements are read/written by different parallel tasks. As it appears from their definition, Read/Write Conflicting variables introduce dependencies between different execution threads and hence prevent the automatic parallelization of the program. The two major techniques used to remove these dependencies are privatization and reduction. In reduction, each thread is provided with a copy of the R/W Conflicting variable to operate on it and produce a partial result, which is then combined with other threads' copies to produce a global result. Another technique similar to privatization is called expansion, in which a scalar variable is expanded into an array, which makes each thread access a different array element. If the variable to be expanded is an array, then expansion adds another dimension to the array. === Limitations === Sometimes a variable can be neither privatized nor reduced to remove the read/write conflict. In these cases, the Read/Write Conflicting variable needs to be updated by different tasks at different points of time. See . This problem can sometimes be solved by changing the scope of parallelism to explore a different parallel region. This might produce good results, as it is often that after reanalyzing the code, some Read/Write Conflicting variables may change to Read/Write Non-conflicting. If the variable still causes conflicts, the last resort is to declaring it as shared and protecting its access by some form of mutual exclusion, and providing synchronization if accesses to the variable needs to happen in a specified order to ensure correctness. === Arrays === Read/Write Conflicting variables can be scalar, or compound types such as arrays, matrices, structured types an so on. Privatization can be applied to both types of variables. When applied to scalar variables, the additional space and overhead introduced by making the extra private copies per thread is relatively small, because scalars are small. However, applying privatization on arrays, matrices or other compound types is much more complex. When dealing with arrays, the compiler tries to analyze the behavior of each array element separately and check for the order it is read and written. If each element is written before it is read in the same iteration, this array can be privatized. To do this, the compiler needs to further analyze the array to combine its accesses into sections. Moreover, the compiler should have extra functions, to be able to manipulate and deal with the array elements. For example, some array expressions may have symbolic terms, hence, to be able to privatize such array, the compiler needs to have some advanced symbolic manipulation functions. x = a; a = b; b = x; x = c; c = d; d = x; x = e; e = f; b = x; This code cannot be made parallel without privatizing x . With x privatized, it can run on three different threads, each with its own private x : //Parallel Code: //Thread 1: x[1] = a; a = b; b = x[1]; // Thread 2: x[2] = c; c = d; d = x[2]; // Thread 3: x[3]= e; e = f; b = x[3]; x = 1; y = x * 3; x = 4; z = y/x; a = x * 9; x = 3; b = a/x; c = x * 1; x = 11; d = c/x; To make the sequential code above parallel, a few lines of code must be added so that x can be privatized: //Parallel Code //Thread 0: x[0] = 1; y = x[0] * 3; x[0] = 4; z = y/x[0]; //Thread 1: x[1] = 4; a = x[1] * 9; x[1] = 3; b = a/x[1]; //Thread 2: x[2] = 3; c = x[2] * 1; x[2] = 11; d = c/x[2]; Because of the extra code, this short example may not actually see much of a speed up. But in real-life, longer code this technique can greatly improve performance. sum = 0; for (i = 0; i This problem can be solved in part by loop unrolling. Because it does not matter which order the elements are added, the loop can be split into an arbitrary number of parts: // Thread 0: sum[0] = 0; for (i[0] = 0; i[0] == OpenMP == OpenMP is a programming language that supports multiprocessor programming with shared memory. Because of this, Read/Write Conflicting variables will undoubtedly occur. In these cases, privatization can sometimes be used to allow parallel execution of the code. Given the sequential code: do i = 10, N - 1 x = (b(i) + c(i))/2 b(i) = a(i + 1) + x enddo For each iteration of the loop, x is written to and then read from. Because x is only a scalar variable, the loop cannot be executed in parallel because it would be overwritten in different threads, and b(i) would not always be assigned the correct value. Equivalent parallelized code using privatization is: !$omp parallel do shared(a, b) private(x) do i = 10, N - 1 x = (b(i) + c(i))/2 b(i) = a(i + 1) + x enddo Because x is declared as private, each thread gets its own copy and the dependence is removed.

References

  1. On privatization of variables for data-parallel execution · retrieved 2026-11-17 · rev 1314517193
    Cite this reference

    MLA "On privatization of variables for data-parallel execution." Gupta, M. 2026-11-17. https://en.wikipedia.org/wiki/CiteSeerX_(identifier). Accessed 24 November 2026.

    Chicago "On privatization of variables for data-parallel execution." Gupta, M. 2026-11-17. https://en.wikipedia.org/wiki/CiteSeerX_(identifier).

    APA Gupta, M. (2026). On privatization of variables for data-parallel execution. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/CiteSeerX_(identifier)

  2. Automatic Array Privatization · retrieved 2026-11-17 · rev 1314517193
    Cite this reference

    MLA "Automatic Array Privatization." Tu, Peng; Padua, David (1993-08-12). 2026-11-17. https://en.wikipedia.org/wiki/David_Gelernter. Accessed 24 November 2026.

    Chicago "Automatic Array Privatization." Tu, Peng; Padua, David (1993-08-12). 2026-11-17. https://en.wikipedia.org/wiki/David_Gelernter.

    APA Tu, Peng; Padua, David (1993-08-12). (2026). Automatic Array Privatization. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/David_Gelernter

  3. Adaptive Reduction Parallelization Techniques · retrieved 2026-11-17 · rev 1314517193
    Cite this reference

    MLA "Adaptive Reduction Parallelization Techniques." Yu, Hao; Rauchwerger, Lawrence (2014-01-01). 2026-11-17. https://en.wikipedia.org/wiki/Lawrence_Rauchwerger. Accessed 24 November 2026.

    Chicago "Adaptive Reduction Parallelization Techniques." Yu, Hao; Rauchwerger, Lawrence (2014-01-01). 2026-11-17. https://en.wikipedia.org/wiki/Lawrence_Rauchwerger.

    APA Yu, Hao; Rauchwerger, Lawrence (2014-01-01). (2026). Adaptive Reduction Parallelization Techniques. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Lawrence_Rauchwerger

  4. Shared-Memory Multiprocessors · retrieved 2026-11-17 · rev 1314517193
    Cite this reference

    MLA "Shared-Memory Multiprocessors." a b Ceze, Luis H. 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier). Accessed 24 November 2026.

    Chicago "Shared-Memory Multiprocessors." a b Ceze, Luis H. 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier).

    APA a b Ceze, Luis H. (2026). Shared-Memory Multiprocessors. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Doi_(identifier)

  5. a b c Chandra, Rohit (2001). Penrose, Denise (ed.). Parallel Programming in OpenMP (PDF) . Morgan Kaufmann . pp. 48, 74, 143. ISBN 978-1-55860-671-5 . Wikipedia revision 1314517193, retrieved 2026-11-18 · retrieved 2026-11-17 · rev 1314517193
    Cite this reference

    MLA "a b c Chandra, Rohit (2001). Penrose, Denise (ed.). Parallel Programming in OpenMP (PDF) . Morgan Kaufmann . pp. 48, 74, 143. ISBN 978-1-55860-671-5 . Wikipedia revision 1314517193, retrieved 2026-11-18." a b c Chandra, Rohit (2001). 2026-11-17. http://lib.mdp.ac.id/ebook/Karya%20Umum/Parallel_Programming_in_OpenMP.pdf. Accessed 24 November 2026.

    Chicago "a b c Chandra, Rohit (2001). Penrose, Denise (ed.). Parallel Programming in OpenMP (PDF) . Morgan Kaufmann . pp. 48, 74, 143. ISBN 978-1-55860-671-5 . Wikipedia revision 1314517193, retrieved 2026-11-18." a b c Chandra, Rohit (2001). 2026-11-17. http://lib.mdp.ac.id/ebook/Karya%20Umum/Parallel_Programming_in_OpenMP.pdf.

    APA a b c Chandra, Rohit (2001). (2026). a b c Chandra, Rohit (2001). Penrose, Denise (ed.). Parallel Programming in OpenMP (PDF) . Morgan Kaufmann . pp. 48, 74, 143. ISBN 978-1-55860-671-5 . Wikipedia revision 1314517193, retrieved 2026-11-18. Retrieved November 24, 2026, from http://lib.mdp.ac.id/ebook/Karya%20Umum/Parallel_Programming_in_OpenMP.pdf

  6. Parallelization, Automatic · retrieved 2026-11-17 · rev 1314517193
    Cite this reference

    MLA "Parallelization, Automatic." a b c d Padua, David (2011-01-01). 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier). Accessed 24 November 2026.

    Chicago "Parallelization, Automatic." a b c d Padua, David (2011-01-01). 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier).

    APA a b c d Padua, David (2011-01-01). (2026). Parallelization, Automatic. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Doi_(identifier)

  7. a b c d e f g h i Solihin, Yan (2015). Fundamentals of Parallel Multicore Architecture . Chapman and Hall/CRC. ISBN 978-1-4822-1118-4 . [ pages needed ] Wikipedia revision 1314517193, retrieved 2026-11-18 · retrieved 2026-11-17 · rev 1314517193
    Cite this reference

    MLA "a b c d e f g h i Solihin, Yan (2015). Fundamentals of Parallel Multicore Architecture . Chapman and Hall/CRC. ISBN 978-1-4822-1118-4 . [ pages needed ] Wikipedia revision 1314517193, retrieved 2026-11-18." a b c d e f g h i Solihin, Yan (2015). 2026-11-17. https://en.wikipedia.org/wiki/ISBN_(identifier). Accessed 24 November 2026.

    Chicago "a b c d e f g h i Solihin, Yan (2015). Fundamentals of Parallel Multicore Architecture . Chapman and Hall/CRC. ISBN 978-1-4822-1118-4 . [ pages needed ] Wikipedia revision 1314517193, retrieved 2026-11-18." a b c d e f g h i Solihin, Yan (2015). 2026-11-17. https://en.wikipedia.org/wiki/ISBN_(identifier).

    APA a b c d e f g h i Solihin, Yan (2015). (2026). a b c d e f g h i Solihin, Yan (2015). Fundamentals of Parallel Multicore Architecture . Chapman and Hall/CRC. ISBN 978-1-4822-1118-4 . [ pages needed ] Wikipedia revision 1314517193, retrieved 2026-11-18. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/ISBN_(identifier)

Cite this article

MLA

"Privatization (computer programming)." encyclopegia.org, 2025, https://encyclopegia.org/wiki/privatization-computer-programming. Accessed 24 November 2026.

Chicago

"Privatization (computer programming)." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/privatization-computer-programming.

APA

encyclopegia.org. (2025). Privatization (computer programming). Retrieved November 24, 2026, from https://encyclopegia.org/wiki/privatization-computer-programming

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1314517193 · 0.5 · snapshot enwiki-001314517193

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.