diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | doc/tmpl/liboil-unused.sgml | 7 | ||||
-rw-r--r-- | doc/tmpl/liboilprofile.sgml | 9 | ||||
-rw-r--r-- | liboil/copy/splat_ref.c | 42 | ||||
-rw-r--r-- | liboil/i386/copy_i386.c | 89 | ||||
-rw-r--r-- | liboil/liboilfunction.c | 29 | ||||
-rw-r--r-- | liboil/liboilprofile.c | 179 | ||||
-rw-r--r-- | liboil/liboilprofile.h | 98 |
8 files changed, 320 insertions, 146 deletions
@@ -1,5 +1,18 @@ 2005-12-22 David Schleef <ds@schleef.org> + * doc/tmpl/liboil-unused.sgml: + * doc/tmpl/liboilprofile.sgml: + * liboil/liboilfunction.c: init_no_optimize() should agree with + oil_init() that the library has been initialized. Also stop + using oil_profile_stamp_gtod() + * liboil/liboilprofile.c: + * liboil/liboilprofile.h: Move all the inline profile functions + to liboilprofile.c. Remove oil_profile_stamp_gtod() + * liboil/copy/splat_ref.c: More impls. + * liboil/i386/copy_i386.c: More impls. + +2005-12-22 David Schleef <ds@schleef.org> + * examples/jpeg/jpeg_rgb_decoder.c: Use new colorspace_argb class. * liboil/colorspace/Makefile.am: remove ayuv2argb.c (broken) diff --git a/doc/tmpl/liboil-unused.sgml b/doc/tmpl/liboil-unused.sgml index d962887..c687bf2 100644 --- a/doc/tmpl/liboil-unused.sgml +++ b/doc/tmpl/liboil-unused.sgml @@ -131,6 +131,13 @@ </para> +<!-- ##### FUNCTION oil_profile_stamp_gtod ##### --> +<para> + +</para> + +@Returns: + <!-- ##### MACRO oil_rand_f32_0_1 ##### --> <para> diff --git a/doc/tmpl/liboilprofile.sgml b/doc/tmpl/liboilprofile.sgml index 92c3850..17ec24a 100644 --- a/doc/tmpl/liboilprofile.sgml +++ b/doc/tmpl/liboilprofile.sgml @@ -30,14 +30,7 @@ -<!-- ##### MACRO oil_profile_stamp ##### --> -<para> - -</para> - - - -<!-- ##### FUNCTION oil_profile_stamp_gtod ##### --> +<!-- ##### FUNCTION oil_profile_stamp ##### --> <para> </para> diff --git a/liboil/copy/splat_ref.c b/liboil/copy/splat_ref.c index ef3601b..275ac80 100644 --- a/liboil/copy/splat_ref.c +++ b/liboil/copy/splat_ref.c @@ -116,4 +116,46 @@ static void splat_u8_ns_int (uint8_t *dest, const uint8_t *param, int n) } OIL_DEFINE_IMPL(splat_u8_ns_int, splat_u8_ns); +static void splat_u8_ns_int2 (uint8_t *dest, const uint8_t *param, int n) +{ + uint32_t p; + while(n&7) { + *dest = *param; + dest++; + n--; + } + n >>= 3; + p = (*param<<24) | (*param<<16) | (*param<<8) | (*param); + while(n>0){ + ((uint32_t *)dest)[0] = p; + ((uint32_t *)dest)[1] = p; + dest+=8; + n--; + } +} +OIL_DEFINE_IMPL(splat_u8_ns_int2, splat_u8_ns); + +static void splat_u8_ns_int4 (uint8_t *dest, const uint8_t *param, int n) +{ + uint32_t p; + while(n&15) { + *dest = *param; + dest++; + n--; + } + n >>= 4; + p = (*param<<24) | (*param<<16) | (*param<<8) | (*param); + while(n>0){ + ((uint32_t *)dest)[0] = p; + ((uint32_t *)dest)[1] = p; + ((uint32_t *)dest)[2] = p; + ((uint32_t *)dest)[3] = p; + dest+=16; + n--; + } +} +OIL_DEFINE_IMPL(splat_u8_ns_int4, splat_u8_ns); + + + diff --git a/liboil/i386/copy_i386.c b/liboil/i386/copy_i386.c index 1a8450b..1bca976 100644 --- a/liboil/i386/copy_i386.c +++ b/liboil/i386/copy_i386.c @@ -30,9 +30,8 @@ #endif #include <liboil/liboilfunction.h> -#include <liboil/liboilfunction.h> +#include <liboil/liboilclasses.h> -OIL_DECLARE_CLASS(copy_u8); static void copy_u8_mmx (uint8_t *dest, uint8_t *src, int n) @@ -246,3 +245,89 @@ copy_u8_mmx5 (uint8_t *dest, uint8_t *src, int n) } OIL_DEFINE_IMPL_FULL (copy_u8_mmx5, copy_u8, OIL_IMPL_FLAG_MMX); + +static void splat_u8_ns_mmx (uint8_t *dest, const uint8_t *param, int n) +{ + uint32_t p; + while(n&7) { + *dest = *param; + dest++; + n--; + } + if (n==0) return; + n >>= 3; + p = (*param<<24) | (*param<<16) | (*param<<8) | (*param); + asm volatile ( + " movd %2, %%mm0\n" + " punpcklbw %%mm0, %%mm0\n" + "1:\n" + " movq %%mm0, (%0)\n" + " add $8, %0\n" + " decl %1\n" + " jnz 1b\n" + " emms\n" + : "+r" (dest), "+r" (n), "+r" (p)); +} +OIL_DEFINE_IMPL(splat_u8_ns_mmx, splat_u8_ns); + +static void splat_u8_ns_mmx2 (uint8_t *dest, const uint8_t *param, int n) +{ + uint32_t p; + while(n&15) { + *dest = *param; + dest++; + n--; + } + if (n==0) return; + n >>= 4; + p = (*param<<24) | (*param<<16) | (*param<<8) | (*param); + asm volatile ( + " movd %2, %%mm0\n" + " punpcklbw %%mm0, %%mm0\n" + "1:\n" + " movq %%mm0, (%0)\n" + " movq %%mm0, 8(%0)\n" + " add $16, %0\n" + " decl %1\n" + " jnz 1b\n" + " emms\n" + : "+r" (dest), "+r" (n), "+r" (p)); +} +OIL_DEFINE_IMPL(splat_u8_ns_mmx2, splat_u8_ns); + +static void splat_u8_ns_mmx2a (uint8_t *dest, const uint8_t *param, int n) +{ + uint32_t p; + p = *param; + p |= p<<8; + p |= p<<16; + if (n<16) { + while(n>0) { + *dest = *param; + dest++; + n--; + } + return; + } + asm volatile ( + " movd %2, %%mm0\n" + " punpcklbw %%mm0, %%mm0\n" + " movq %%mm0, (%0)\n" + " movq %%mm0, 8(%0)\n" + " movl %1, %%eax\n" + " and $0xf, %%eax\n" + " add %%eax, %0\n" + " shr $4, %1\n" + "1:\n" + " movq %%mm0, (%0)\n" + " movq %%mm0, 8(%0)\n" + " add $16, %0\n" + " decl %1\n" + " jnz 1b\n" + " emms\n" + : "+r" (dest), "+r" (n), "+r" (p) + : + : "eax"); +} +OIL_DEFINE_IMPL(splat_u8_ns_mmx2a, splat_u8_ns); + diff --git a/liboil/liboilfunction.c b/liboil/liboilfunction.c index 968e779..d622d4d 100644 --- a/liboil/liboilfunction.c +++ b/liboil/liboilfunction.c @@ -103,6 +103,7 @@ static void oil_init_pointers (void); static void oil_init_structs (void); void _oil_cpu_init (void); +void _oil_profile_init (void); /** * SECTION:liboilinit @@ -123,29 +124,23 @@ void _oil_cpu_init (void); * * Since: 0.3.0 */ +static int _oil_inited = 0; void oil_init (void) { - static int inited = 0; - unsigned long start, stop; - if (inited) return; - inited = 1; - - start = oil_profile_stamp_gtod (); + if (_oil_inited) return; + _oil_inited = 1; _oil_debug_init (); _oil_cpu_init (); + _oil_profile_init (); oil_init_pointers (); oil_init_structs (); oil_cpu_fault_check_enable (); oil_optimize_all (); oil_cpu_fault_check_disable (); - - stop = oil_profile_stamp_gtod (); - - OIL_INFO ("initialization completed in %ld usec", stop-start); } /** @@ -158,22 +153,14 @@ oil_init (void) void oil_init_no_optimize (void) { - static int inited = 0; - unsigned long start, stop; - - if (inited) return; - inited = 1; - - start = oil_profile_stamp_gtod (); + if (_oil_inited) return; + _oil_inited = 1; _oil_debug_init (); _oil_cpu_init (); + _oil_profile_init (); oil_init_pointers (); oil_init_structs (); - - stop = oil_profile_stamp_gtod (); - - OIL_INFO ("initialization completed in %ld usec", stop-start); } /** diff --git a/liboil/liboilprofile.c b/liboil/liboilprofile.c index f3ca8dd..60ffa56 100644 --- a/liboil/liboilprofile.c +++ b/liboil/liboilprofile.c @@ -30,6 +30,7 @@ #endif #include <liboil/liboilprofile.h> +#include <liboil/liboildebug.h> #include <sys/time.h> #include <time.h> @@ -45,24 +46,6 @@ */ /** - * oil_profile_stamp_gtod: - * - * Creates a timestamp using the function gettimofday(). - * - * Returns: a timestamp - */ -unsigned long oil_profile_stamp_gtod (void) -{ -#ifdef HAVE_GETTIMEOFDAY - struct timeval tv; - gettimeofday(&tv,NULL); - return 1000000*(unsigned long)tv.tv_sec + (unsigned long)tv.tv_usec; -#else - return 0; -#endif -} - -/** * oil_profile_init: * @prof: the OilProfile structure * @@ -164,3 +147,163 @@ oil_profile_get_ave_std (OilProfile *prof, double *ave_p, double *std_p) } + +#if defined(__i386__) || defined(__amd64__) +static unsigned long +oil_profile_stamp_tsc(void) +{ + unsigned long ts; + __asm__ __volatile__("rdtsc\n" : "=a" (ts) : : "edx"); + return ts; +} +#endif + +#if defined(__powerpc__) +static unsigned long +oil_profile_stamp_tb(void) +{ + unsigned long ts; + __asm__ __volatile__("mftb %0\n" : "=r" (ts)); + return ts; +} +#endif + +#if defined(__alpha__) +static unsigned long +oil_profile_stamp_counter(void) +{ + unsigned int ts; + __asm__ __volatile__ ("rpcc %0\n" : "=r"(ts)); + return ts; +} +#endif + +#if defined(__ia64__) +static unsigned long +oil_profile_stamp_counter(void) +{ + unsigned int ts; + __asm__ __volatile__("mov %0=ar.itc\n" : "=r"(ts) :: "memory"); + return ts; +} +#endif + +#if defined(__s390__) +static unsigned long +oil_profile_stamp_counter(void) +{ + uint64_t ts; + __asm__ __volatile__ ("STCK 0(%0)\n" : : "r" (&ts)); + return ts; +} +#endif + +#if defined(__mips__) && 0 +/* broken */ +static unsigned long +oil_profile_stamp_mips(void) +{ + unsigned int ts; + __asm__ __volatile__ ( + " .set push \n" + " .set reorder \n" + " mfc0 %0,$9 \n" + " .set pop \n" + : "=m" (ts)); + return ts; +} +#endif + +#if defined(__arm__) +/* untested */ +static unsigned long +oil_profile_stamp_xcale255(void) +{ + unsigned int ts; + /* this only works for XScale 255 */ + __asm__ __volatile__ ( + " mrc p14, 0, %0, c0, c0, 0 \n" + : "=r" (ts)); + return ts; +} +#endif + +#ifdef HAVE_GETTIMEOFDAY +static unsigned long +oil_profile_stamp_gtod (void) +{ + struct timeval tv; + gettimeofday(&tv,NULL); + return 1000000*(unsigned long)tv.tv_sec + (unsigned long)tv.tv_usec; +} +#endif + +static unsigned long +oil_profile_stamp_zero (void) +{ + return 0; +} + +static unsigned long (*_oil_profile_stamp)(void); + +/** + * oil_profile_stamp: + * + * Creates a timestamp based on a CPU-specific high-frequency + * counter, if available. + * + * Returns: a timestamp + */ +unsigned long +oil_profile_stamp (void) +{ + return _oil_profile_stamp(); +} + +void +_oil_profile_init (void) +{ +#if defined(__i386__) +#define have_tsc 1 + if (have_tsc) { + _oil_profile_stamp = oil_profile_stamp_tsc; + } +#endif +#if defined(__amd64__) + _oil_profile_stamp = oil_profile_stamp_tsc; +#endif +#if defined(__powerpc__) + _oil_profile_stamp = oil_profile_stamp_tb; +#endif +#if defined(__alpha__) + _oil_profile_stamp = oil_profile_stamp_counter; +#endif +#if defined(__ia64__) + _oil_profile_stamp = oil_profile_stamp_counter; +#endif +#if defined(__s390__) + _oil_profile_stamp = oil_profile_stamp_counter; +#endif +#if defined(__mips__) && 0 + _oil_profile_stamp = oil_profile_stamp_mips; +#endif +#if defined(__arm__) + if (0) { + /* need to detect XScale 255 */ + _oil_profile_stamp = oil_profile_stamp_xscale255; + } +#endif + +#ifdef HAVE_GETTIMEOFDAY + if (_oil_profile_stamp == NULL) { + _oil_profile_stamp = oil_profile_stamp_gtod; + OIL_ERROR("Using gettimeofday() as a timestamp function. Please add a timestamp function for your platform."); + } +#endif + + if (_oil_profile_stamp == NULL) { + _oil_profile_stamp = oil_profile_stamp_zero; + OIL_ERROR("No timestamping function. This is kinda bad."); + } +} + diff --git a/liboil/liboilprofile.h b/liboil/liboilprofile.h index 07add5b..adf716c 100644 --- a/liboil/liboilprofile.h +++ b/liboil/liboilprofile.h @@ -57,103 +57,7 @@ struct _OilProfile { int hist_count[OIL_PROFILE_HIST_LENGTH]; }; -/** - * oil_profile_stamp: - * - * Creates a timestamp based on a CPU-specific high-frequency - * counter, if available. - * - * Returns: a timestamp - */ -#if defined(__i386__) - -static inline unsigned long oil_profile_stamp(void) -{ - unsigned long ts; - __asm__ __volatile__("rdtsc\n" : "=a" (ts) : : "edx"); - return ts; -} - -#elif defined(__amd64__) - -static inline unsigned long oil_profile_stamp(void) -{ - unsigned long ts; - __asm__ __volatile__("rdtsc\n" : "=a" (ts) : : "edx"); - return ts; -} - -#elif defined(__powerpc__) - -static inline unsigned long oil_profile_stamp(void) -{ - unsigned long ts; - __asm__ __volatile__("mftb %0\n" : "=r" (ts)); - return ts; -} - -#elif defined(__alpha__) - -static inline unsigned long oil_profile_stamp(void) -{ - unsigned int ts; - __asm__ __volatile__ ("rpcc %0\n" : "=r"(ts)); - return ts; -} - -#elif defined(__ia64__) - -static inline unsigned long oil_profile_stamp(void) -{ - unsigned int ts; - __asm__ __volatile__("mov %0=ar.itc\n" : "=r"(ts) :: "memory"); - return ts; -} - -#elif defined(__s390__) - -static inline unsigned long oil_profile_stamp(void) -{ - uint64_t ts; - __asm__ __volatile__ ("STCK %0\n" : "=m" (ts)); - return ts; -} - -#elif defined(__mips__) && 0 - -/* broken */ -static inline unsigned long oil_profile_stamp(void) -{ - unsigned int ts; - __asm__ __volatile__ ( - " .set push \n" - " .set reorder \n" - " mfc0 %0,$9 \n" - " .set pop \n" - : "=m" (ts)); - return ts; -} - -#elif defined(__arm__) - -/* untested */ -static inline unsigned long oil_profile_stamp(void) -{ - unsigned int ts; - /* this only works for XScale 255 */ - __asm__ __volatile__ ( - " mrc p14, 0, %0, c0, c0, 0 \n" - : "=r" (ts)); - return ts; -} - -#else - -#define oil_profile_stamp() oil_profile_stamp_gtod() - -#endif - -unsigned long oil_profile_stamp_gtod (void); +unsigned long oil_profile_stamp(void); void oil_profile_init(OilProfile *prof); void oil_profile_stop_handle(OilProfile *prof); void oil_profile_get_ave_std (OilProfile *prof, double *ave_p, double *std_p); |