From 41e2d1e3f25c730a7ced190e1800dceb2d936d85 Mon Sep 17 00:00:00 2001 From: Michael Hemmer Date: Tue, 16 Sep 2008 11:28:48 +0000 Subject: [PATCH] test for thread safty of CGAL::Residue --- .gitattributes | 1 + .../test/Modular_arithmetic/multi_threads.cpp | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Modular_arithmetic/test/Modular_arithmetic/multi_threads.cpp diff --git a/.gitattributes b/.gitattributes index 07a186ac979..031673cfb01 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2518,6 +2518,7 @@ Modular_arithmetic/doc_tex/Modular_arithmetic_ref/main.tex -text Modular_arithmetic/examples/Modular_arithmetic/modular_filter.cpp -text Modular_arithmetic/include/CGAL/Modular_arithmetic/Residue_type.h -text Modular_arithmetic/test/Modular_arithmetic/Modular_traits.cpp -text +Modular_arithmetic/test/Modular_arithmetic/multi_threads.cpp -text Nef_2/demo/Nef_2/filtered_homogeneous_data/complex.nef -text svneol=native#application/octet-stream Nef_2/demo/Nef_2/filtered_homogeneous_data/symmdif.nef -text svneol=native#application/octet-stream Nef_2/demo/Nef_2/help/index.html svneol=native#text/html diff --git a/Modular_arithmetic/test/Modular_arithmetic/multi_threads.cpp b/Modular_arithmetic/test/Modular_arithmetic/multi_threads.cpp new file mode 100644 index 00000000000..ddb4cabd5ad --- /dev/null +++ b/Modular_arithmetic/test/Modular_arithmetic/multi_threads.cpp @@ -0,0 +1,35 @@ +// Author(s) : Michael Hemmer + +#include +#include +#include +#include +#include + +#ifdef _OPENMP +#include +// This file needs Open MP. +// Use ,e.g. , gcc-4.3.1 with -fopenmp and -lgomp +int main () { + int tid; + + //Beginning of parallel section. Fork a team of threads. + //Specify variable scoping +#pragma omp parallel private(tid) + { + tid = omp_get_thread_num(); + int old_prime = CGAL::CGALi::primes[0]; + int new_prime = CGAL::CGALi::primes[tid+1]; + assert(CGAL::Residue::get_current_prime() == old_prime); + CGAL::Residue::set_current_prime(new_prime); + assert(CGAL::Residue::get_current_prime() == new_prime); + + typedef CGAL::Residue NT; + typedef CGAL::Field_tag Tag; + typedef CGAL::Tag_true Is_exact; + CGAL::test_algebraic_structure(); + } +} +#else +int main (){} +#endif