more UNBUF fixes
try to keep compat better, remove the single-thread-first-tile idea
This commit is contained in:
parent
959f412380
commit
a4d3c2a754
8
TODO
8
TODO
@ -1,15 +1,9 @@
|
|||||||
- seq no longer stalls ahead threads ... instead, we rely on sinkdisk
|
- seq no longer stalls ahead threads ... instead, we rely on sinkdisk
|
||||||
interlocks to limit how far ahead or behind threads can get
|
interlocks to limit how far ahead or behind threads can get
|
||||||
|
|
||||||
deprecate UNBUFFERED? it will probably not work now
|
|
||||||
|
|
||||||
remove single-thread-first-tile thing
|
|
||||||
|
|
||||||
the readbehind option to many loaders is no longer needed
|
the readbehind option to many loaders is no longer needed
|
||||||
|
|
||||||
do we need to restore the UNBUFFERED enum member to keep binary compat? we
|
check pforeign.h
|
||||||
need to make sure old code using UNBUFF now uses regular SEQ (and not RAND)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,6 +262,7 @@ vips_sequential_init( VipsSequential *sequential )
|
|||||||
sequential->lock = vips_g_mutex_new();
|
sequential->lock = vips_g_mutex_new();
|
||||||
sequential->tile_height = 1;
|
sequential->tile_height = 1;
|
||||||
sequential->error = 0;
|
sequential->error = 0;
|
||||||
|
sequential->access = VIPS_ACCESS_SEQUENTIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,6 +280,7 @@ vips_tile_search_recycle( gpointer key, gpointer value, gpointer user_data )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_ACCESS_SEQUENTIAL:
|
case VIPS_ACCESS_SEQUENTIAL:
|
||||||
|
case VIPS_ACCESS_SEQUENTIAL_UNBUFFERED:
|
||||||
if( tile->pos.top < search->topmost ) {
|
if( tile->pos.top < search->topmost ) {
|
||||||
search->topmost = tile->pos.top;
|
search->topmost = tile->pos.top;
|
||||||
search->tile = tile;
|
search->tile = tile;
|
||||||
|
@ -129,13 +129,10 @@ typedef enum {
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
VIPS_ACCESS_RANDOM,
|
VIPS_ACCESS_RANDOM,
|
||||||
VIPS_ACCESS_SEQUENTIAL,
|
VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
VIPS_ACCESS_SEQUENTIAL_UNBUFFERED,
|
||||||
VIPS_ACCESS_LAST
|
VIPS_ACCESS_LAST
|
||||||
} VipsAccess;
|
} VipsAccess;
|
||||||
|
|
||||||
/* Compat for a mode we used to support.
|
|
||||||
*/
|
|
||||||
#define VIPS_ACCESS_SEQUENTIAL_UNBUFFERED VIPS_ACCESS_SEQUENTIAL
|
|
||||||
|
|
||||||
struct _VipsImage;
|
struct _VipsImage;
|
||||||
struct _VipsRegion;
|
struct _VipsRegion;
|
||||||
|
|
||||||
|
@ -669,6 +669,7 @@ vips_access_get_type( void )
|
|||||||
static const GEnumValue values[] = {
|
static const GEnumValue values[] = {
|
||||||
{VIPS_ACCESS_RANDOM, "VIPS_ACCESS_RANDOM", "random"},
|
{VIPS_ACCESS_RANDOM, "VIPS_ACCESS_RANDOM", "random"},
|
||||||
{VIPS_ACCESS_SEQUENTIAL, "VIPS_ACCESS_SEQUENTIAL", "sequential"},
|
{VIPS_ACCESS_SEQUENTIAL, "VIPS_ACCESS_SEQUENTIAL", "sequential"},
|
||||||
|
{VIPS_ACCESS_SEQUENTIAL_UNBUFFERED, "VIPS_ACCESS_SEQUENTIAL_UNBUFFERED", "sequential-unbuffered"},
|
||||||
{VIPS_ACCESS_LAST, "VIPS_ACCESS_LAST", "last"},
|
{VIPS_ACCESS_LAST, "VIPS_ACCESS_LAST", "last"},
|
||||||
{0, NULL, NULL}
|
{0, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -1816,6 +1816,7 @@ vips_object_set_argument_from_string( VipsObject *object,
|
|||||||
if( g_type_is_a( otype, VIPS_TYPE_IMAGE ) ) {
|
if( g_type_is_a( otype, VIPS_TYPE_IMAGE ) ) {
|
||||||
VipsImage *out;
|
VipsImage *out;
|
||||||
VipsOperationFlags flags;
|
VipsOperationFlags flags;
|
||||||
|
VipsAccess access;
|
||||||
|
|
||||||
if( !value ) {
|
if( !value ) {
|
||||||
vips_object_no_value( object, name );
|
vips_object_no_value( object, name );
|
||||||
@ -1827,12 +1828,15 @@ vips_object_set_argument_from_string( VipsObject *object,
|
|||||||
flags = vips_operation_get_flags(
|
flags = vips_operation_get_flags(
|
||||||
VIPS_OPERATION( object ) );
|
VIPS_OPERATION( object ) );
|
||||||
|
|
||||||
/* Read the filename.
|
if( flags &
|
||||||
*/
|
(VIPS_OPERATION_SEQUENTIAL |
|
||||||
|
VIPS_OPERATION_SEQUENTIAL_UNBUFFERED) )
|
||||||
|
access = VIPS_ACCESS_SEQUENTIAL;
|
||||||
|
else
|
||||||
|
access = VIPS_ACCESS_RANDOM;
|
||||||
|
|
||||||
if( !(out = vips_image_new_from_file( value,
|
if( !(out = vips_image_new_from_file( value,
|
||||||
"access", flags & VIPS_OPERATION_SEQUENTIAL ?
|
"access", access,
|
||||||
VIPS_ACCESS_SEQUENTIAL : VIPS_ACCESS_RANDOM,
|
|
||||||
NULL )) )
|
NULL )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -1851,6 +1855,7 @@ vips_object_set_argument_from_string( VipsObject *object,
|
|||||||
*/
|
*/
|
||||||
VipsArrayImage *array_image;
|
VipsArrayImage *array_image;
|
||||||
VipsOperationFlags flags;
|
VipsOperationFlags flags;
|
||||||
|
VipsAccess access;
|
||||||
|
|
||||||
if( !value ) {
|
if( !value ) {
|
||||||
vips_object_no_value( object, name );
|
vips_object_no_value( object, name );
|
||||||
@ -1862,9 +1867,15 @@ vips_object_set_argument_from_string( VipsObject *object,
|
|||||||
flags = vips_operation_get_flags(
|
flags = vips_operation_get_flags(
|
||||||
VIPS_OPERATION( object ) );
|
VIPS_OPERATION( object ) );
|
||||||
|
|
||||||
if( !(array_image = vips_array_image_new_from_string( value,
|
if( flags &
|
||||||
flags & VIPS_OPERATION_SEQUENTIAL ?
|
(VIPS_OPERATION_SEQUENTIAL |
|
||||||
VIPS_ACCESS_SEQUENTIAL : VIPS_ACCESS_RANDOM )) )
|
VIPS_OPERATION_SEQUENTIAL_UNBUFFERED) )
|
||||||
|
access = VIPS_ACCESS_SEQUENTIAL;
|
||||||
|
else
|
||||||
|
access = VIPS_ACCESS_RANDOM;
|
||||||
|
|
||||||
|
if( !(array_image =
|
||||||
|
vips_array_image_new_from_string( value, access )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
g_value_init( &gvalue, VIPS_TYPE_ARRAY_IMAGE );
|
g_value_init( &gvalue, VIPS_TYPE_ARRAY_IMAGE );
|
||||||
|
@ -548,12 +548,6 @@ typedef struct _VipsThreadpool {
|
|||||||
/* Set by Allocate (via an arg) to indicate normal end of computation.
|
/* Set by Allocate (via an arg) to indicate normal end of computation.
|
||||||
*/
|
*/
|
||||||
gboolean stop;
|
gboolean stop;
|
||||||
|
|
||||||
/* Set by the first thread to hit allocate. The first work unit runs
|
|
||||||
* single-threaded to give loaders a change to get to the right spot
|
|
||||||
* in the input.
|
|
||||||
*/
|
|
||||||
gboolean done_first;
|
|
||||||
} VipsThreadpool;
|
} VipsThreadpool;
|
||||||
|
|
||||||
/* Junk a thread.
|
/* Junk a thread.
|
||||||
@ -635,8 +629,7 @@ vips_thread_work_unit( VipsThread *thr )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pool->done_first )
|
g_mutex_unlock( pool->allocate_lock );
|
||||||
g_mutex_unlock( pool->allocate_lock );
|
|
||||||
|
|
||||||
/* Process a work unit.
|
/* Process a work unit.
|
||||||
*/
|
*/
|
||||||
@ -644,11 +637,6 @@ vips_thread_work_unit( VipsThread *thr )
|
|||||||
thr->error = TRUE;
|
thr->error = TRUE;
|
||||||
pool->error = TRUE;
|
pool->error = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !pool->done_first ) {
|
|
||||||
pool->done_first = TRUE;
|
|
||||||
g_mutex_unlock( pool->allocate_lock );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* What runs as a thread ... loop, waiting to be told to do stuff.
|
/* What runs as a thread ... loop, waiting to be told to do stuff.
|
||||||
@ -781,7 +769,6 @@ vips_threadpool_new( VipsImage *im )
|
|||||||
vips_semaphore_init( &pool->tick, 0, "tick" );
|
vips_semaphore_init( &pool->tick, 0, "tick" );
|
||||||
pool->error = FALSE;
|
pool->error = FALSE;
|
||||||
pool->stop = FALSE;
|
pool->stop = FALSE;
|
||||||
pool->done_first = FALSE;
|
|
||||||
|
|
||||||
/* If this is a tiny image, we won't need all nthr threads. Guess how
|
/* If this is a tiny image, we won't need all nthr threads. Guess how
|
||||||
* many tiles we might need to cover the image and use that to limit
|
* many tiles we might need to cover the image and use that to limit
|
||||||
|
@ -562,7 +562,7 @@ vips_reduceh_class_init( VipsReducehClass *reduceh_class )
|
|||||||
vobject_class->description = _( "shrink an image horizontally" );
|
vobject_class->description = _( "shrink an image horizontally" );
|
||||||
vobject_class->build = vips_reduceh_build;
|
vobject_class->build = vips_reduceh_build;
|
||||||
|
|
||||||
operation_class->flags = VIPS_OPERATION_SEQUENTIAL_UNBUFFERED;
|
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
|
||||||
|
|
||||||
VIPS_ARG_DOUBLE( reduceh_class, "hshrink", 3,
|
VIPS_ARG_DOUBLE( reduceh_class, "hshrink", 3,
|
||||||
_( "Hshrink" ),
|
_( "Hshrink" ),
|
||||||
|
@ -895,7 +895,7 @@ vips_reducev_class_init( VipsReducevClass *reducev_class )
|
|||||||
vobject_class->description = _( "shrink an image vertically" );
|
vobject_class->description = _( "shrink an image vertically" );
|
||||||
vobject_class->build = vips_reducev_build;
|
vobject_class->build = vips_reducev_build;
|
||||||
|
|
||||||
operation_class->flags = VIPS_OPERATION_SEQUENTIAL_UNBUFFERED;
|
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
|
||||||
|
|
||||||
VIPS_ARG_DOUBLE( reducev_class, "vshrink", 3,
|
VIPS_ARG_DOUBLE( reducev_class, "vshrink", 3,
|
||||||
_( "Vshrink" ),
|
_( "Vshrink" ),
|
||||||
|
@ -631,8 +631,6 @@ vips_thumbnail_file_open( VipsThumbnail *thumbnail, int shrink, double scale )
|
|||||||
{
|
{
|
||||||
VipsThumbnailFile *file = (VipsThumbnailFile *) thumbnail;
|
VipsThumbnailFile *file = (VipsThumbnailFile *) thumbnail;
|
||||||
|
|
||||||
/* We can't use UNBUFERRED safely on very-many-core systems.
|
|
||||||
*/
|
|
||||||
if( shrink != 1 )
|
if( shrink != 1 )
|
||||||
return( vips_image_new_from_file( file->filename,
|
return( vips_image_new_from_file( file->filename,
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
@ -795,8 +793,6 @@ vips_thumbnail_buffer_open( VipsThumbnail *thumbnail,
|
|||||||
{
|
{
|
||||||
VipsThumbnailBuffer *buffer = (VipsThumbnailBuffer *) thumbnail;
|
VipsThumbnailBuffer *buffer = (VipsThumbnailBuffer *) thumbnail;
|
||||||
|
|
||||||
/* We can't use UNBUFERRED safely on very-many-core systems.
|
|
||||||
*/
|
|
||||||
if( shrink != 1 )
|
if( shrink != 1 )
|
||||||
return( vips_image_new_from_buffer(
|
return( vips_image_new_from_buffer(
|
||||||
buffer->buf->data, buffer->buf->length, "",
|
buffer->buf->data, buffer->buf->length, "",
|
||||||
|
Loading…
Reference in New Issue
Block a user