2013-01-19 02:32:58 +04:00
|
|
|
/* test_sign.c
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2013-01-19 23:27:34 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2013-02-27 18:58:06 +04:00
|
|
|
#include <winpr/sysinfo.h>
|
2013-01-19 02:32:58 +04:00
|
|
|
#include "prim_test.h"
|
|
|
|
|
|
|
|
static const int SIGN_PRETEST_ITERATIONS = 100000;
|
|
|
|
static const float TEST_TIME = 1.0;
|
|
|
|
|
|
|
|
extern pstatus_t general_sign_16s(const INT16 *pSrc, INT16 *pDst, int len);
|
2013-02-28 13:49:39 +04:00
|
|
|
#ifdef WITH_SSE2
|
2013-01-19 02:32:58 +04:00
|
|
|
extern pstatus_t ssse3_sign_16s(const INT16 *pSrc, INT16 *pDst, int len);
|
2013-02-28 13:49:39 +04:00
|
|
|
#endif
|
2013-01-19 02:32:58 +04:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
int test_sign16s_func(void)
|
|
|
|
{
|
2013-02-28 13:49:39 +04:00
|
|
|
INT16 ALIGN(src[65535]), ALIGN(d1[65535]);
|
|
|
|
#ifdef WITH_SSE2
|
|
|
|
INT16 ALIGN(d2[65535]);
|
2013-01-19 02:32:58 +04:00
|
|
|
int i;
|
2013-02-28 13:49:39 +04:00
|
|
|
#endif
|
|
|
|
int failed = 0;
|
2013-01-19 02:32:58 +04:00
|
|
|
char testStr[256];
|
|
|
|
|
|
|
|
/* Test when we can reach 16-byte alignment */
|
|
|
|
testStr[0] = '\0';
|
|
|
|
get_random_data(src, sizeof(src));
|
|
|
|
general_sign_16s(src+1, d1+1, 65535);
|
2013-02-28 13:49:39 +04:00
|
|
|
#ifdef WITH_SSE2
|
2013-02-27 18:58:06 +04:00
|
|
|
if (IsProcessorFeaturePresentEx(PF_EX_SSSE3))
|
2013-01-19 02:32:58 +04:00
|
|
|
{
|
|
|
|
strcat(testStr, " SSSE3");
|
|
|
|
ssse3_sign_16s(src+1, d2+1, 65535);
|
|
|
|
for (i=1; i<65535; ++i)
|
|
|
|
{
|
|
|
|
if (d1[i] != d2[i])
|
|
|
|
{
|
|
|
|
printf("SIGN16s-SSE-aligned FAIL[%d] of %d: want %d, got %d\n",
|
|
|
|
i, src[i], d1[i], d2[i]);
|
|
|
|
++failed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* i386 */
|
|
|
|
|
|
|
|
/* Test when we cannot reach 16-byte alignment */
|
|
|
|
get_random_data(src, sizeof(src));
|
|
|
|
general_sign_16s(src+1, d1+2, 65535);
|
2013-02-28 13:49:39 +04:00
|
|
|
#ifdef WITH_SSE2
|
2013-02-27 18:58:06 +04:00
|
|
|
if (IsProcessorFeaturePresentEx(PF_EX_SSSE3))
|
2013-01-19 02:32:58 +04:00
|
|
|
{
|
|
|
|
ssse3_sign_16s(src+1, d2+2, 65535);
|
|
|
|
for (i=2; i<65535; ++i)
|
|
|
|
{
|
|
|
|
if (d1[i] != d2[i])
|
|
|
|
{
|
|
|
|
printf("SIGN16s-SSE-unaligned FAIL[%d] of %d: want %d, got %d\n",
|
|
|
|
i, src[i-1], d1[i], d2[i]);
|
|
|
|
++failed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* i386 */
|
|
|
|
if (!failed) printf("All sign16s tests passed (%s).\n", testStr);
|
|
|
|
return (failed > 0) ? FAILURE : SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
STD_SPEED_TEST(sign16s_speed_test, INT16, INT16, dst=dst,
|
|
|
|
TRUE, general_sign_16s(src1, dst, size),
|
2013-02-28 13:49:39 +04:00
|
|
|
#ifdef WITH_SSE2
|
2013-02-27 18:58:06 +04:00
|
|
|
TRUE, ssse3_sign_16s(src1, dst, size), PF_EX_SSSE3, TRUE,
|
2013-02-28 13:49:39 +04:00
|
|
|
#else
|
|
|
|
FALSE, PRIM_NOP, 0, FALSE,
|
|
|
|
#endif
|
2013-01-19 02:32:58 +04:00
|
|
|
FALSE, dst=dst);
|
|
|
|
|
|
|
|
int test_sign16s_speed(void)
|
|
|
|
{
|
|
|
|
INT16 ALIGN(src[MAX_TEST_SIZE+3]), ALIGN(dst[MAX_TEST_SIZE+3]);
|
|
|
|
get_random_data(src, sizeof(src));
|
|
|
|
sign16s_speed_test("sign16s", "aligned", src, NULL, 0, dst,
|
|
|
|
test_sizes, NUM_TEST_SIZES, SIGN_PRETEST_ITERATIONS, TEST_TIME);
|
|
|
|
sign16s_speed_test("sign16s", "unaligned", src+1, NULL, 0, dst,
|
|
|
|
test_sizes, NUM_TEST_SIZES, SIGN_PRETEST_ITERATIONS, TEST_TIME);
|
|
|
|
return SUCCESS;
|
|
|
|
}
|