From 55d78a4dcf3876910155e541bf7202aa8a082d28 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 15 Mar 2010 18:11:36 +0000 Subject: [PATCH] stuff --- ChangeLog | 2 ++ TODO | 6 ------ configure.in | 2 +- libvips/iofuncs/threadgroup.c | 29 ++++++++++++++++++++++++----- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ea4c39d..e7dbc8c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -32,6 +32,8 @@ - im_render() mask image generation no longer triggers image calc - threadgroups scale output buffers with number of threads for smalltile ... improves SMP scaling for narrow images on many-way machines +- default to max number of processors (--vips-concurrency and IM_CONCURRENCY + set >0 can override) on linux and win32 15/1/10 started 7.21.1 - added "written" callbacks, used to implement write to non-vips formats diff --git a/TODO b/TODO index 77a573c7..0f94d31e 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,3 @@ -- try - - vips im_rot90 babe.jpg test2.v - - wtf, thinstrip output o.O - - doing im_create_fmask() and friends - how about im_invalidate_area()? we currently repaint the whole window on diff --git a/configure.in b/configure.in index 4351aa7c..b6351ae1 100644 --- a/configure.in +++ b/configure.in @@ -213,7 +213,7 @@ AC_TYPE_SIZE_T AC_FUNC_MEMCMP AC_FUNC_MMAP AC_FUNC_VPRINTF -AC_CHECK_FUNCS([getcwd gettimeofday getwd memset munmap putenv realpath strcasecmp strchr strcspn strdup strerror strrchr strspn vsnprintf realpath mkstemp mktemp random rand]) +AC_CHECK_FUNCS([getcwd gettimeofday getwd memset munmap putenv realpath strcasecmp strchr strcspn strdup strerror strrchr strspn vsnprintf realpath mkstemp mktemp random rand sysconf]) AC_CHECK_LIB(m,cbrt,[AC_DEFINE(HAVE_CBRT,1,[have cbrt() in libm.])]) AC_CHECK_LIB(m,hypot,[AC_DEFINE(HAVE_HYPOT,1,[have hypot() in libm.])]) diff --git a/libvips/iofuncs/threadgroup.c b/libvips/iofuncs/threadgroup.c index 0edb8a32..9cea5f0f 100644 --- a/libvips/iofuncs/threadgroup.c +++ b/libvips/iofuncs/threadgroup.c @@ -146,17 +146,32 @@ im_concurrency_get( void ) { const char *str; int nthr; + int x; /* Tell the threads system how much concurrency we expect. */ if( im__concurrency > 0 ) nthr = im__concurrency; - else if( (str = g_getenv( IM_CONCURRENCY )) ) - nthr = atoi( str ); - else - /* Stick to minimum. - */ + else if( (str = g_getenv( IM_CONCURRENCY )) && + (x = atoi( str )) > 0 ) + nthr = x; + else { nthr = 1; +#ifdef HAVE_SYSCONF +{ + x = sysconf( _SC_NPROCESSORS_ONLN ); + if( x > 0 ) + nthr = x; +} +#endif /*HAVE_SYSCONF*/ +#ifdef OS_WIN32 + SYSTEM_INFO si; + + GetSystemInfo( &si ); + + nthr = si.dwNumberOfProcessors; +#endif /*OS_WIN32*/ + } if( nthr < 1 || nthr > IM_MAX_THREADS ) { nthr = IM_CLIP( 1, nthr, IM_MAX_THREADS ); @@ -165,6 +180,10 @@ im_concurrency_get( void ) _( "threads clipped to %d" ), nthr ); } + /* Save for next time around. + */ + im_concurrency_set( nthr ); + /* FIXME .. hmm