From: joncruz Date: Tue, 25 Nov 2008 03:44:36 +0000 (+0000) Subject: Fixed OpenMP dependency to be optional. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=feb17b9e0c9468a8dfb5cb424718d0953f4109ea;p=inkscape.git Fixed OpenMP dependency to be optional. --- diff --git a/configure.ac b/configure.ac index 37c4ddb04..d33502000 100644 --- a/configure.ac +++ b/configure.ac @@ -144,10 +144,16 @@ dnl ****************************** dnl Check for OpenMP dnl ****************************** -AX_OPENMP(,AC_MSG_ERROR([Inkscape requires OpenMP support to build])) -dnl We have it, now set up the flags -CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS" -AC_CHECK_HEADER(omp.h) +AX_OPENMP([openmp_ok=yes],[openmp_ok=no]) +AC_MSG_CHECKING([for OpenMP support]) +dnl a bit odd, but AX_OPENMP does its own check message, so we're not wrapping it at the moment +AC_MSG_RESULT([$openmp_ok]) +if test "x$openmp_ok" = "xyes"; then + dnl We have it, now set up the flags + CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS" + AC_CHECK_HEADER(omp.h) +fi + dnl ****************************** dnl Check for libpng @@ -672,7 +678,11 @@ if test "x$cairo_pdf" = "xyes"; then fi dnl Shouldn't we test for libpng and libz? -INKSCAPE_LIBS="$INKSCAPE_LIBS -lpng -lz -lgomp" +if test "x$openmp_ok" = "xyes"; then + INKSCAPE_LIBS="$INKSCAPE_LIBS -lpng -lz -lgomp" +else + INKSCAPE_LIBS="$INKSCAPE_LIBS -lpng -lz" +fi AC_CHECK_HEADER(popt.h, [INKSCAPE_LIBS="$INKSCAPE_LIBS -lpopt"], diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 4cbd7957d..d92a7f7f3 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -19,7 +19,9 @@ #include #include #include +#if HAVE_OPENMP #include +#endif //HAVE_OPENMP #include "2geom/isnan.h" @@ -271,9 +273,15 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, int const n1, int const n2, IIRValue const b[N+1], double const M[N*N], IIRValue *const tmpdata[], int const num_threads) { +#if HAVE_OPENMP #pragma omp parallel for num_threads(num_threads) +#endif // HAVE_OPENMP for ( int c2 = 0 ; c2 < n2 ; c2++ ) { +#if HAVE_OPENMP unsigned int tid = omp_get_thread_num(); +#else + unsigned int tid = 0; +#endif // HAVE_OPENMP // corresponding line in the source and output buffer PT const * srcimg = src + c2*sstr2; PT * dstimg = dest + c2*dstr2 + n1*dstr1; @@ -334,7 +342,9 @@ filter2D_FIR(PT *const dst, int const dstr1, int const dstr2, // Past pixels seen (to enable in-place operation) PT history[scr_len+1][PC]; +#if HAVE_OPENMP #pragma omp parallel for num_threads(num_threads) private(history) +#endif // HAVE_OPENMP for ( int c2 = 0 ; c2 < n2 ; c2++ ) { // corresponding line in the source buffer @@ -548,7 +558,11 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units) double const deviation_x_org = _deviation_x * NR::expansionX(trans); double const deviation_y_org = _deviation_y * NR::expansionY(trans); int const PC = NR_PIXBLOCK_BPP(in); +#if HAVE_OPENMP int const NTHREADS = std::max(1,std::min(8,prefs->getInt("/options/threading/numthreads",omp_get_num_procs()))); +#else + int const NTHREADS = 1; +#endif // HAVE_OPENMP // Subsampling constants int const quality = prefs->getInt("/options/blurquality/value");