libfreerdp-primitives: migrate tests to ctest

This commit is contained in:
Marc-André Moreau 2014-09-04 15:46:20 -04:00
parent 37aabc50d1
commit ccb31efe63
15 changed files with 390 additions and 617 deletions

View File

@ -100,6 +100,6 @@ endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")
if(BUILD_TESTING AND ((NOT WIN32) AND (NOT APPLE))) if(BUILD_TESTING AND ((NOT WIN32) AND (NOT APPLE)))
# add_subdirectory(test) add_subdirectory(test)
endif() endif()

View File

@ -1,2 +1,3 @@
prim_test prim_test
TestPrimitives.c

View File

@ -1,155 +1,49 @@
# FreeRDP: A Remote Desktop Protocol Client
# primitives test makefile builder
# vi:ts=4 sw=4:
#
# (c) Copyright 2012 Hewlett-Packard Development Company, L.P.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing permissions
# and limitations under the License.
#
# TODO: Integrate this into the testing framework, in some form. set(MODULE_NAME "TestPrimitives")
# Right now this produces a standalone test that covers both functionality set(MODULE_PREFIX "TEST_FREERDP_PRIMITIVES")
# and performance of the primitives library entrypoints.
cmake_minimum_required(VERSION 2.8) set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
set(MODULE_NAME "prim_test")
set(MODULE_PREFIX "PRIMITIVES_LIBRARY_TEST")
set(PRIMITIVE_TEST_CFILES set(${MODULE_PREFIX}_TESTS
TestPrimitives16to32bpp.c
TestPrimitivesAdd.c
TestPrimitivesAlphaComp.c
TestPrimitivesAndOr.c
TestPrimitivesColors.c
TestPrimitivesCopy.c
TestPrimitivesSet.c
TestPrimitivesShift.c
TestPrimitivesSign.c
TestPrimitivesYCoCg.c)
create_test_sourcelist(${MODULE_PREFIX}_SRCS
${${MODULE_PREFIX}_DRIVER}
${${MODULE_PREFIX}_TESTS})
set(${MODULE_PREFIX}_EXTRA_SRCS
prim_test.c prim_test.c
test_16to32bpp.c
test_add.c
test_alphaComp.c
test_andor.c
test_colors.c
test_copy.c
test_set.c
test_shift.c
test_sign.c
test_YCoCg.c
../prim_16to32bpp.c
../prim_add.c
../prim_andor.c
../prim_alphaComp.c
../prim_colors.c
../prim_copy.c
../prim_set.c
../prim_shift.c
../prim_sign.c
../prim_YCoCg.c
../prim_16to32bpp_opt.c
../prim_add_opt.c
../prim_alphaComp_opt.c
../prim_andor_opt.c
../prim_colors_opt.c
../prim_set_opt.c
../prim_shift_opt.c
../prim_sign_opt.c
../prim_YCoCg_opt.c
../primitives.c
)
set(PRIMITIVE_TEST_HEADERS
measure.h
prim_test.h prim_test.h
../prim_internal.h measure.h)
)
set(PRIMITIVE_TEST_SRCS add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_EXTRA_SRCS})
${PRIMITIVE_TEST_CFILES}
${PRIMITIVE_TEST_HEADERS}
)
include_directories(. ../../.. ../../../include ../../../winpr/include) set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
add_definitions(-DPRIM_STATIC=auto -DALL_PRIMITIVES_VERSIONS -DHAVE_CONFIG_H) MONOLITHIC ${MONOLITHIC_BUILD}
MODULE freerdp
MODULES freerdp-primitives)
# If these haven't been set by the caller, set them now to defaults. set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr)
if(NOT DEFINED WITH_IPP)
set(WITH_IPP FALSE)
endif()
if(NOT DEFINED WITH_SSE2)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*")
set(WITH_SSE2 FALSE)
else()
set(WITH_SSE2 TRUE)
endif()
endif()
if(NOT DEFINED WITH_NEON)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*")
set(WITH_NEON TRUE)
else()
set(WITH_NEON FALSE)
endif()
endif()
if(WITH_SSE2) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(CMAKE_COMPILER_IS_GNUCC)
set(OPTFLAGS "${OPTFLAGS} -msse2 -mssse3 -O2 -Wdeclaration-after-statement")
endif()
if(MSVC) add_definitions(-DPRIM_STATIC=auto -DALL_PRIMITIVES_VERSIONS)
set(OPTFLAGS "${OPTFLAGS} /arch:SSE2")
endif()
elseif(WITH_NEON)
if(CMAKE_COMPILER_IS_GNUCC)
set(OPTFLAGS "${OPTFLAGS} -mfpu=neon -mfloat-abi=${ARM_FP_ABI} -O2")
endif()
# TODO: Add MSVC equivalent
endif()
add_executable(prim_test ${PRIMITIVE_TEST_SRCS}) set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}")
if(WITH_IPP) foreach(test ${${MODULE_PREFIX}_TESTS})
if(NOT DEFINED IPP_FOUND) get_filename_component(TestName ${test} NAME_WE)
include(../../../cmake/FindIPP.cmake) add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName})
endif() endforeach()
# IPP PATH debugging messages
message(IPP_FOUND=${IPP_FOUND})
message(IPP_VERSION_STR=${IPP_VERSION_STR})
message(IPP_VERSION_MAJOR=${IPP_VERSION_MAJOR})
message(IPP_VERSION_MINOR=${IPP_VERSION_MINOR})
message(IPP_VERSION_BUILD=${IPP_VERSION_BUILD})
message(IPP_ROOT_DIR=${IPP_ROOT_DIR})
message(IPP_INCLUDE_DIRS=${IPP_INCLUDE_DIRS})
message(IPP_LIBRARY_DIRS=${IPP_LIBRARY_DIRS})
message(IPP_LIBRARIES=${IPP_LIBRARIES})
message(IPP_COMPILER_LIBRARY_DIRS=${IPP_COMPILER_LIBRARY_DIRS})
message(IPP_COMPILER_LIBRARIES=${IPP_COMPILER_LIBRARIES})
message(IPP_LIBRARY_LIST=${IPP_LIBRARY_LIST})
message(IPP_LIB_PREFIX=${IPP_LIB_PREFIX})
message(IPP_LIB_SUFFIX=${IPP_LIB_SUFFIX})
message(IPP_PREFIX=${IPP_PREFIX})
message(IPP_SUFFIX=${IPP_SUFFIX})
message(IPPCORE=${IPPCORE})
message(IPPS=${IPPS})
message(IPPI=${IPPI})
message(IPPCC=${IPPCC})
message(IPPCV=${IPPCV})
message(IPPVM=${IPPVM})
if(CMAKE_COMPILER_IS_GNUCC)
foreach(INCLDIR ${IPP_INCLUDE_DIRS})
set(OPTFLAGS "${OPTFLAGS} -I${INCLDIR}")
endforeach(INCLDIR)
endif()
target_link_libraries(prim_test ${IPP_LIBRARY_LIST})
endif()
set_property(SOURCE ${PRIMITIVE_TEST_CFILES} PROPERTY COMPILE_FLAGS ${OPTFLAGS})
find_library(WINPR_SYSINFO NAMES winpr-sysinfo HINTS ../../../winpr/libwinpr/sysinfo)
target_link_libraries(prim_test rt ${WINPR_SYSINFO})
if(NOT TESTING_OUTPUT_DIRECTORY)
set(TESTING_OUTPUT_DIRECTORY .)
endif()
add_test(prim_test ${TESTING_OUTPUT_DIRECTORY}/prim_test functionality)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/Test") set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/Test")

View File

@ -28,6 +28,8 @@
static const int RGB_TRIAL_ITERATIONS = 1000; static const int RGB_TRIAL_ITERATIONS = 1000;
static const float TEST_TIME = 4.0; static const float TEST_TIME = 4.0;
extern BOOL g_TestPrimitivesPerformance;
extern pstatus_t general_RGB565ToARGB_16u32u_C3C4( extern pstatus_t general_RGB565ToARGB_16u32u_C3C4(
const UINT16* pSrc, INT32 srcStep, const UINT16* pSrc, INT32 srcStep,
UINT32* pDst, INT32 dstStep, UINT32* pDst, INT32 dstStep,
@ -134,7 +136,7 @@ static BOOL try_16To32(
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
int test_RGB565ToARGB_16u32u_C3C4_func(void) int test_RGB565ToARGB_16u32u_C3C4_func(void)
{ {
INT16 ALIGN(data16[4096+3]); UINT16 ALIGN(data16[4096+3]);
BOOL success; BOOL success;
success = TRUE; success = TRUE;
@ -176,7 +178,6 @@ int test_RGB565ToARGB_16u32u_C3C4_speed(void)
{ {
UINT16 ALIGN(src[4096]); UINT16 ALIGN(src[4096]);
UINT32 ALIGN(dst[4096]); UINT32 ALIGN(dst[4096]);
int i;
int size_array[] = { 64 }; int size_array[] = { 64 };
get_random_data(src, sizeof(src)); get_random_data(src, sizeof(src));
@ -186,3 +187,23 @@ int test_RGB565ToARGB_16u32u_C3C4_speed(void)
size_array, 1, RGB_TRIAL_ITERATIONS, TEST_TIME); size_array, 1, RGB_TRIAL_ITERATIONS, TEST_TIME);
return SUCCESS; return SUCCESS;
} }
int TestPrimitives16to32bpp(int argc, char* argv[])
{
int status;
status = test_RGB565ToARGB_16u32u_C3C4_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_RGB565ToARGB_16u32u_C3C4_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -23,6 +23,8 @@
static const int ADD16S_PRETEST_ITERATIONS = 300000*64; static const int ADD16S_PRETEST_ITERATIONS = 300000*64;
static const int TEST_TIME = 2.0; // seconds static const int TEST_TIME = 2.0; // seconds
extern BOOL g_TestPrimitivesPerformance;
extern pstatus_t general_add_16s( extern pstatus_t general_add_16s(
const INT16 *pSrc1, const INT16 *pSrc2, INT16 *pDst, int len); const INT16 *pSrc1, const INT16 *pSrc2, INT16 *pDst, int len);
extern pstatus_t sse3_add_16s( extern pstatus_t sse3_add_16s(
@ -112,3 +114,23 @@ int test_add16s_speed(void)
test_sizes, NUM_TEST_SIZES, ADD16S_PRETEST_ITERATIONS, TEST_TIME); test_sizes, NUM_TEST_SIZES, ADD16S_PRETEST_ITERATIONS, TEST_TIME);
return SUCCESS; return SUCCESS;
} }
int TestPrimitivesAdd(int argc, char* argv[])
{
int status;
status = test_add16s_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_add16s_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -22,6 +22,8 @@
static const int ALPHA_PRETEST_ITERATIONS = 5000000; static const int ALPHA_PRETEST_ITERATIONS = 5000000;
static const float TEST_TIME = 5.0; static const float TEST_TIME = 5.0;
extern BOOL g_TestPrimitivesPerformance;
static const int block_size[] = { 4, 64, 256 }; static const int block_size[] = { 4, 64, 256 };
#define NUM_BLOCK_SIZES (sizeof(block_size)/sizeof(int)) #define NUM_BLOCK_SIZES (sizeof(block_size)/sizeof(int))
#define MAX_BLOCK_SIZE 256 #define MAX_BLOCK_SIZE 256
@ -233,3 +235,23 @@ int test_alphaComp_speed(void)
return SUCCESS; return SUCCESS;
} }
int TestPrimitivesAlphaComp(int argc, char* argv[])
{
int status;
status = test_alphaComp_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_alphaComp_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -23,6 +23,8 @@
static const int ANDOR_PRETEST_ITERATIONS = 100000; static const int ANDOR_PRETEST_ITERATIONS = 100000;
static const int TEST_TIME = 2.0; // seconds static const int TEST_TIME = 2.0; // seconds
extern BOOL g_TestPrimitivesPerformance;
extern pstatus_t general_andC_32u(const UINT32 *pSrc, UINT32 val, extern pstatus_t general_andC_32u(const UINT32 *pSrc, UINT32 val,
UINT32 *pDst, int len); UINT32 *pDst, int len);
extern pstatus_t sse3_andC_32u(const UINT32 *pSrc, UINT32 val, extern pstatus_t sse3_andC_32u(const UINT32 *pSrc, UINT32 val,
@ -185,3 +187,36 @@ int test_or_32u_speed(void)
test_sizes, NUM_TEST_SIZES, ANDOR_PRETEST_ITERATIONS, TEST_TIME); test_sizes, NUM_TEST_SIZES, ANDOR_PRETEST_ITERATIONS, TEST_TIME);
return SUCCESS; return SUCCESS;
} }
int TestPrimitivesAndOr(int argc, char* argv[])
{
int status;
status = test_and_32u_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_and_32u_speed();
if (status != SUCCESS)
return 1;
}
status = test_or_32u_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_or_32u_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -23,6 +23,8 @@ static const int RGB_TRIAL_ITERATIONS = 1000;
static const int YCBCR_TRIAL_ITERATIONS = 1000; static const int YCBCR_TRIAL_ITERATIONS = 1000;
static const float TEST_TIME = 4.0; static const float TEST_TIME = 4.0;
extern BOOL g_TestPrimitivesPerformance;
extern pstatus_t general_RGBToRGB_16s8u_P3AC4R(const INT16 *pSrc[3], extern pstatus_t general_RGBToRGB_16s8u_P3AC4R(const INT16 *pSrc[3],
int srcStep, BYTE *pDst, int dstStep, const prim_size_t *roi); int srcStep, BYTE *pDst, int dstStep, const prim_size_t *roi);
extern pstatus_t sse2_RGBToRGB_16s8u_P3AC4R(const INT16 *pSrc[3], extern pstatus_t sse2_RGBToRGB_16s8u_P3AC4R(const INT16 *pSrc[3],
@ -241,3 +243,36 @@ int test_yCbCrToRGB_16s16s_P3P3_speed(void)
size_array, 1, YCBCR_TRIAL_ITERATIONS, TEST_TIME); size_array, 1, YCBCR_TRIAL_ITERATIONS, TEST_TIME);
return SUCCESS; return SUCCESS;
} }
int TestPrimitivesColors(int argc, char* argv[])
{
int status;
status = test_RGBToRGB_16s8u_P3AC4R_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_RGBToRGB_16s8u_P3AC4R_speed();
if (status != SUCCESS)
return 1;
}
status = test_yCbCrToRGB_16s16s_P3P3_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_yCbCrToRGB_16s16s_P3P3_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -26,6 +26,8 @@ static const int TEST_TIME = 1.0; // seconds
extern pstatus_t sse3_copy_8u(const BYTE *pSrc, BYTE *pDst, int len); extern pstatus_t sse3_copy_8u(const BYTE *pSrc, BYTE *pDst, int len);
#endif #endif
extern BOOL g_TestPrimitivesPerformance;
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
int test_copy8u_func(void) int test_copy8u_func(void)
{ {
@ -84,3 +86,23 @@ int test_copy8u_speed(void)
test_sizes, NUM_TEST_SIZES, MEMCPY_PRETEST_ITERATIONS, TEST_TIME); test_sizes, NUM_TEST_SIZES, MEMCPY_PRETEST_ITERATIONS, TEST_TIME);
return SUCCESS; return SUCCESS;
} }
int TestPrimitivesCopy(int argc, char* argv[])
{
int status;
status = test_copy8u_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_copy8u_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -23,6 +23,8 @@ static const int MEMSET8_PRETEST_ITERATIONS = 100000000;
static const int MEMSET32_PRETEST_ITERATIONS = 40000000; static const int MEMSET32_PRETEST_ITERATIONS = 40000000;
static const float TEST_TIME = 1.0; static const float TEST_TIME = 1.0;
extern BOOL g_TestPrimitivesPerformance;
extern pstatus_t general_set_8u(BYTE val, BYTE *pDst, int len); extern pstatus_t general_set_8u(BYTE val, BYTE *pDst, int len);
extern pstatus_t sse2_set_8u(BYTE val, BYTE *pDst, int len); extern pstatus_t sse2_set_8u(BYTE val, BYTE *pDst, int len);
extern pstatus_t general_set_32s(INT32 val, INT32 *pDst, int len); extern pstatus_t general_set_32s(INT32 val, INT32 *pDst, int len);
@ -303,3 +305,49 @@ int test_set32s_speed(void)
#endif #endif
return SUCCESS; return SUCCESS;
} }
int TestPrimitivesSet(int argc, char* argv[])
{
int status;
status = test_set8u_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_set8u_speed();
if (status != SUCCESS)
return 1;
}
status = test_set32s_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_set32s_speed();
if (status != SUCCESS)
return 1;
}
status = test_set32u_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_set32u_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -23,6 +23,8 @@
static const int SHIFT_PRETEST_ITERATIONS = 50000; static const int SHIFT_PRETEST_ITERATIONS = 50000;
static const float TEST_TIME = 1.0; static const float TEST_TIME = 1.0;
extern BOOL g_TestPrimitivesPerformance;
extern pstatus_t general_lShiftC_16s( extern pstatus_t general_lShiftC_16s(
const INT16 *pSrc, int val, INT16 *pDst, int len); const INT16 *pSrc, int val, INT16 *pDst, int len);
extern pstatus_t general_rShiftC_16s( extern pstatus_t general_rShiftC_16s(
@ -187,3 +189,62 @@ int test_rShift_16u_speed(void)
test_sizes, NUM_TEST_SIZES, SHIFT_PRETEST_ITERATIONS, TEST_TIME); test_sizes, NUM_TEST_SIZES, SHIFT_PRETEST_ITERATIONS, TEST_TIME);
return SUCCESS; return SUCCESS;
} }
int TestPrimitivesShift(int argc, char* argv[])
{
int status;
status = test_lShift_16s_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_lShift_16s_speed();
if (status != SUCCESS)
return 1;
}
status = test_lShift_16u_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_lShift_16u_speed();
if (status != SUCCESS)
return 1;
}
status = test_rShift_16s_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_rShift_16s_speed();
if (status != SUCCESS)
return 1;
}
status = test_rShift_16u_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_rShift_16u_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -22,6 +22,8 @@
static const int SIGN_PRETEST_ITERATIONS = 100000; static const int SIGN_PRETEST_ITERATIONS = 100000;
static const float TEST_TIME = 1.0; static const float TEST_TIME = 1.0;
extern BOOL g_TestPrimitivesPerformance;
extern pstatus_t general_sign_16s(const INT16 *pSrc, INT16 *pDst, int len); extern pstatus_t general_sign_16s(const INT16 *pSrc, INT16 *pDst, int len);
#ifdef WITH_SSE2 #ifdef WITH_SSE2
extern pstatus_t ssse3_sign_16s(const INT16 *pSrc, INT16 *pDst, int len); extern pstatus_t ssse3_sign_16s(const INT16 *pSrc, INT16 *pDst, int len);
@ -101,3 +103,23 @@ int test_sign16s_speed(void)
test_sizes, NUM_TEST_SIZES, SIGN_PRETEST_ITERATIONS, TEST_TIME); test_sizes, NUM_TEST_SIZES, SIGN_PRETEST_ITERATIONS, TEST_TIME);
return SUCCESS; return SUCCESS;
} }
int TestPrimitivesSign(int argc, char* argv[])
{
int status;
status = test_sign16s_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_sign16s_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -26,6 +26,8 @@
static const int YCOCG_TRIAL_ITERATIONS = 20000; static const int YCOCG_TRIAL_ITERATIONS = 20000;
static const float TEST_TIME = 4.0; static const float TEST_TIME = 4.0;
extern BOOL g_TestPrimitivesPerformance;
extern pstatus_t general_YCoCgRToRGB_8u_AC4R(const BYTE *pSrc, INT32 srcStep, extern pstatus_t general_YCoCgRToRGB_8u_AC4R(const BYTE *pSrc, INT32 srcStep,
BYTE *pDst, INT32 dstStep, UINT32 width, UINT32 height, BYTE *pDst, INT32 dstStep, UINT32 width, UINT32 height,
UINT8 shift, BOOL withAlpha, BOOL invert); UINT8 shift, BOOL withAlpha, BOOL invert);
@ -97,7 +99,6 @@ int test_YCoCgRToRGB_8u_AC4R_speed(void)
{ {
INT32 ALIGN(in[4096]); INT32 ALIGN(in[4096]);
INT32 ALIGN(out[4096]); INT32 ALIGN(out[4096]);
int i;
int size_array[] = { 64 }; int size_array[] = { 64 };
get_random_data(in, sizeof(in)); get_random_data(in, sizeof(in));
@ -107,3 +108,23 @@ int test_YCoCgRToRGB_8u_AC4R_speed(void)
size_array, 1, YCOCG_TRIAL_ITERATIONS, TEST_TIME); size_array, 1, YCOCG_TRIAL_ITERATIONS, TEST_TIME);
return SUCCESS; return SUCCESS;
} }
int TestPrimitivesYCoCg(int argc, char* argv[])
{
int status;
status = test_YCoCgRToRGB_8u_AC4R_func();
if (status != SUCCESS)
return 1;
if (g_TestPrimitivesPerformance)
{
status = test_YCoCgRToRGB_8u_AC4R_speed();
if (status != SUCCESS)
return 1;
}
return 0;
}

View File

@ -18,108 +18,22 @@
#include "prim_test.h" #include "prim_test.h"
#include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h>
#include <winpr/platform.h>
#include <winpr/sysinfo.h> #include <winpr/sysinfo.h>
#include <winpr/platform.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <stdlib.h> BOOL g_TestPrimitivesPerformance = FALSE;
#include <time.h>
int test_sizes[] = { 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 }; int test_sizes[] = { 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
int Quiet = 0;
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
typedef struct static void get_random_data_lrand(void *buffer, size_t size)
{
UINT32 flag;
const char *str;
} flagpair_t;
static const flagpair_t flags[] =
{
#ifdef _M_IX86_AMD64
{ PF_MMX_INSTRUCTIONS_AVAILABLE, "MMX" },
{ PF_3DNOW_INSTRUCTIONS_AVAILABLE, "3DNow" },
{ PF_SSE_INSTRUCTIONS_AVAILABLE, "SSE" },
{ PF_SSE2_INSTRUCTIONS_AVAILABLE, "SSE2" },
{ PF_SSE3_INSTRUCTIONS_AVAILABLE, "SSE3" },
#elif defined(_M_ARM)
{ PF_ARM_VFP3, "VFP3" },
{ PF_ARM_INTEL_WMMX, "IWMMXT" },
{ PF_ARM_NEON_INSTRUCTIONS_AVAILABLE, "NEON" },
#endif
};
static const flagpair_t flags_extended[] =
{
#ifdef _M_IX86_AMD64
{ PF_EX_3DNOW_PREFETCH, "3DNow-PF" },
{ PF_EX_SSSE3, "SSSE3" },
{ PF_EX_SSE41, "SSE4.1" },
{ PF_EX_SSE42, "SSE4.2" },
{ PF_EX_AVX, "AVX" },
{ PF_EX_FMA, "FMA" },
{ PF_EX_AVX_AES, "AVX-AES" },
{ PF_EX_AVX2, "AVX2" },
#elif defined(_M_ARM)
{ PF_EX_ARM_VFP1, "VFP1"},
{ PF_EX_ARM_VFP4, "VFP4" },
#endif
};
void primitives_flags_str(char* str, size_t len)
{
int i;
*str = '\0';
--len; /* for the '/0' */
for (i = 0; i < sizeof(flags) / sizeof(flagpair_t); ++i)
{
if (IsProcessorFeaturePresent(flags[i].flag))
{
int slen = strlen(flags[i].str) + 1;
if (len < slen)
break;
if (*str != '\0')
strcat(str, " ");
strcat(str, flags[i].str);
len -= slen;
}
}
for (i = 0; i < sizeof(flags_extended) / sizeof(flagpair_t); ++i)
{
if (IsProcessorFeaturePresentEx(flags_extended[i].flag))
{
int slen = strlen(flags_extended[i].str) + 1;
if (len < slen)
break;
if (*str != '\0')
strcat(str, " ");
strcat(str, flags_extended[i].str);
len -= slen;
}
}
}
/* ------------------------------------------------------------------------- */
static void get_random_data_lrand(
void *buffer,
size_t size)
{ {
static int seeded = 0; static int seeded = 0;
long int *ptr = (long int *) buffer; long int *ptr = (long int *) buffer;
@ -145,11 +59,9 @@ static void get_random_data_lrand(
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
void get_random_data( void get_random_data(void *buffer, size_t size)
void *buffer,
size_t size)
{ {
#ifdef linux #ifdef __linux__
size_t offset = 0; size_t offset = 0;
int fd = open("/dev/urandom", O_RDONLY); int fd = open("/dev/urandom", O_RDONLY);
if (fd < 0) if (fd < 0)
@ -171,9 +83,7 @@ void get_random_data(
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
float _delta_time( float _delta_time(const struct timespec *t0, const struct timespec *t1)
const struct timespec *t0,
const struct timespec *t1)
{ {
INT64 secs = (INT64) (t1->tv_sec) - (INT64) (t0->tv_sec); INT64 secs = (INT64) (t1->tv_sec) - (INT64) (t0->tv_sec);
long nsecs = t1->tv_nsec - t0->tv_nsec; long nsecs = t1->tv_nsec - t0->tv_nsec;
@ -184,14 +94,13 @@ float _delta_time(
--secs; --secs;
nsecs += 1000000000; nsecs += 1000000000;
} }
retval = (double) secs + (double) nsecs / (double) 1000000000.0; retval = (double) secs + (double) nsecs / (double) 1000000000.0;
return (retval < 0.0) ? 0.0 : (float) retval; return (retval < 0.0) ? 0.0 : (float) retval;
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
void _floatprint( void _floatprint(float t, char *output)
float t,
char *output)
{ {
/* I don't want to link against -lm, so avoid log,exp,... */ /* I don't want to link against -lm, so avoid log,exp,... */
float f = 10.0; float f = 10.0;
@ -210,334 +119,3 @@ void _floatprint(
i/1000000000, (i % 1000000000) / 1000000); i/1000000000, (i % 1000000000) / 1000000);
else sprintf(output, "%f", t); else sprintf(output, "%f", t);
} }
/* ------------------------------------------------------------------------- */
/* Specific areas to test: */
#define TEST_COPY8 (1<<0)
#define TEST_SET8 (1<<1)
#define TEST_SET32S (1<<2)
#define TEST_SET32U (1<<3)
#define TEST_SIGN16S (1<<4)
#define TEST_ADD16S (1<<5)
#define TEST_LSHIFT16S (1<<6)
#define TEST_LSHIFT16U (1<<7)
#define TEST_RSHIFT16S (1<<8)
#define TEST_RSHIFT16U (1<<9)
#define TEST_RGB (1<<10)
#define TEST_ALPHA (1<<11)
#define TEST_AND (1<<12)
#define TEST_OR (1<<13)
#define TEST_YCOCG (1<<14)
#define TEST_16TO32 (1<<15)
/* Specific types of testing: */
#define TEST_FUNCTIONALITY (1<<0)
#define TEST_PERFORMANCE (1<<1)
/* ------------------------------------------------------------------------- */
typedef struct
{
const char *testStr;
UINT32 bits;
} test_t;
static const test_t testList[] =
{
{ "all", 0xFFFFFFFFU },
{ "copy", TEST_COPY8 },
{ "copy8", TEST_COPY8 },
{ "set", TEST_SET8|TEST_SET32S|TEST_SET32U },
{ "set8", TEST_SET8 },
{ "set32", TEST_SET32S|TEST_SET32U },
{ "set32s", TEST_SET32S },
{ "set32u", TEST_SET32U },
{ "sign", TEST_SIGN16S },
{ "sign16s", TEST_SIGN16S },
{ "add", TEST_ADD16S },
{ "add16s", TEST_ADD16S },
{ "lshift", TEST_LSHIFT16S|TEST_LSHIFT16U },
{ "rshift", TEST_RSHIFT16S|TEST_RSHIFT16U },
{ "shift", TEST_LSHIFT16S|TEST_LSHIFT16U|TEST_RSHIFT16S|TEST_RSHIFT16U },
{ "lshift16s", TEST_LSHIFT16S },
{ "lshift16u", TEST_LSHIFT16U },
{ "rshift16s", TEST_RSHIFT16S },
{ "rshift16u", TEST_RSHIFT16U },
{ "rgb", TEST_RGB },
{ "color", TEST_RGB },
{ "colors", TEST_RGB },
{ "ycocg", TEST_YCOCG },
{ "alpha", TEST_ALPHA },
{ "and", TEST_AND },
{ "or", TEST_OR },
{ "16to32", TEST_16TO32 }
};
#define NUMTESTS (sizeof(testList)/sizeof(test_t))
static const test_t testTypeList[] =
{
{ "functionality", TEST_FUNCTIONALITY },
{ "performance", TEST_PERFORMANCE },
};
#define NUMTESTTYPES (sizeof(testTypeList)/sizeof(test_t))
int main(int argc, char** argv)
{
int i;
char hints[1024];
UINT32 testSet = 0;
UINT32 testTypes = 0;
int results = SUCCESS;
/* Parse command line for the test set. */
for (i = 1; i < argc; ++i)
{
int j;
BOOL found = 0;
for (j=0; j<NUMTESTS; ++j)
{
if (strcasecmp(argv[i], testList[j].testStr) == 0)
{
testSet |= testList[j].bits;
found = 1;
break;
}
}
for (j=0; j<NUMTESTTYPES; ++j)
{
if (strcasecmp(argv[i], testTypeList[j].testStr) == 0)
{
testTypes |= testTypeList[j].bits;
found = 1;
break;
}
}
if (!found)
{
if (strstr(argv[i], "help") != NULL)
{
printf("Available tests:\n");
for (j=0; j<NUMTESTS; ++j)
{
printf(" %s\n", testList[j].testStr);
}
for (j=0; j<NUMTESTTYPES; ++j)
{
printf(" %s\n", testTypeList[j].testStr);
}
}
else fprintf(stderr, "Unknown parameter '%s'!\n", argv[i]);
}
}
if (testSet == 0)
testSet = 0xffffffff;
if (testTypes == 0)
testTypes = 0xffffffff;
primitives_init();
primitives_flags_str(hints, sizeof(hints));
printf("Hints: %s\n", hints);
/* COPY */
if (testSet & TEST_COPY8)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_copy8u_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_copy8u_speed();
}
}
/* SET */
if (testSet & TEST_SET8)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_set8u_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_set8u_speed();
}
}
if (testSet & TEST_SET32S)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_set32s_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_set32s_speed();
}
}
if (testSet & TEST_SET32U)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_set32u_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_set32u_speed();
}
}
/* SIGN */
if (testSet & TEST_SIGN16S)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_sign16s_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_sign16s_speed();
}
}
/* ADD */
if (testSet & TEST_ADD16S)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_add16s_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_add16s_speed();
}
}
/* SHIFTS */
if (testSet & TEST_LSHIFT16S)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_lShift_16s_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_lShift_16s_speed();
}
}
if (testSet & TEST_LSHIFT16U)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_lShift_16u_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_lShift_16u_speed();
}
}
if (testSet & TEST_RSHIFT16S)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_rShift_16s_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_rShift_16s_speed();
}
}
if (testSet & TEST_RSHIFT16U)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_rShift_16u_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_rShift_16u_speed();
}
}
/* COLORS */
if (testSet & TEST_RGB)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_RGBToRGB_16s8u_P3AC4R_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_RGBToRGB_16s8u_P3AC4R_speed();
}
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_yCbCrToRGB_16s16s_P3P3_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_yCbCrToRGB_16s16s_P3P3_speed();
}
}
if (testSet & TEST_YCOCG)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_YCoCgRToRGB_8u_AC4R_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_YCoCgRToRGB_8u_AC4R_speed();
}
}
/* 16 to 32 BPP */
if (testSet & TEST_16TO32)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_RGB565ToARGB_16u32u_C3C4_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_RGB565ToARGB_16u32u_C3C4_speed();
}
}
/* ALPHA COMPOSITION */
if (testSet & TEST_ALPHA)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_alphaComp_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_alphaComp_speed();
}
}
/* AND & OR */
if (testSet & TEST_AND)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_and_32u_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_and_32u_speed();
}
}
if (testSet & TEST_OR)
{
if (testTypes & TEST_FUNCTIONALITY)
{
results |= test_or_32u_func();
}
if (testTypes & TEST_PERFORMANCE)
{
results |= test_or_32u_speed();
}
}
primitives_deinit();
return results;
}

View File

@ -20,31 +20,22 @@
#ifndef __PRIMTEST_H_INCLUDED__ #ifndef __PRIMTEST_H_INCLUDED__
#define __PRIMTEST_H_INCLUDED__ #define __PRIMTEST_H_INCLUDED__
#include <config.h> #include <winpr/crt.h>
#include <stdint.h> #include <winpr/spec.h>
#include <winpr/wtypes.h> #include <winpr/wtypes.h>
#include <winpr/platform.h>
#include <measure.h>
#include <string.h>
#include <stdio.h>
#include <freerdp/primitives.h> #include <freerdp/primitives.h>
#include <winpr/platform.h>
#include "measure.h"
#ifdef WITH_IPP #ifdef WITH_IPP
#include <ipps.h> #include <ipps.h>
#include <ippi.h> #include <ippi.h>
#endif #endif
#define BLOCK_ALIGNMENT 16 #define ALIGN(x) x DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT)
#ifdef __GNUC__
#define ALIGN(x) x __attribute((aligned(BLOCK_ALIGNMENT)))
#define POSSIBLY_UNUSED(x) x __attribute((unused))
#else
/* TODO: Someone needs to finish this for non-GNU C */
#define ALIGN(x) x
#define POSSIBLY_UNUSED(x) x
#endif
#define ABS(_x_) ((_x_) < 0 ? (-(_x_)) : (_x_)) #define ABS(_x_) ((_x_) < 0 ? (-(_x_)) : (_x_))
#define MAX_TEST_SIZE 4096 #define MAX_TEST_SIZE 4096