summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7e4a57f)
raw | patch | inline | side by side (parent: 7e4a57f)
author | Jianzhong Xu <xuj@ti.com> | |
Fri, 20 May 2016 19:35:37 +0000 (19:35 +0000) | ||
committer | Jianzhong Xu <xuj@ti.com> | |
Fri, 20 May 2016 19:35:37 +0000 (19:35 +0000) |
src/ti/linalg/tuning/common/comp_matrix.c | [new file with mode: 0644] | patch | blob |
src/ti/linalg/tuning/make.inc | patch | blob | history |
diff --git a/src/ti/linalg/tuning/common/comp_matrix.c b/src/ti/linalg/tuning/common/comp_matrix.c
--- /dev/null
@@ -0,0 +1,162 @@
+/******************************************************************************
+ * Copyright (c) 2013-2016, Texas Instruments Incorporated - http://www.ti.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Texas Instruments Incorporated nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <complex.h>
+
+/*-----------------------------------------------------------------------------
+* Compare two single precision complex matrices
+*----------------------------------------------------------------------------*/
+int comp_matrix_complex(const float complex *C1, const float complex *C2, int M, int N)
+{
+ int i;
+ float norm, delta;
+ const float EPISILON = 1e-5;
+ const float DELTA = 1e-5;
+ const int NERRORS = 5;
+ int num_errors = 0;
+
+ for (i=0; i<M*N; i++)
+ {
+ delta = cabs(C1[i]) - cabs(C2[i]);
+ norm = cabs(C1[i]);
+ if(norm < cabs(C2[i])) {
+ norm = cabs(C2[i]);
+ }
+
+ if (delta > EPISILON*norm && delta>DELTA) {
+ if ((num_errors += 1) < NERRORS) {
+ printf("Error [elem:%d]: %f <==> %f\n", i, cabs(C1[i]), cabs(C2[i]));
+ }
+ }
+ }
+
+ if (num_errors > 0) {
+ printf("FAIL with %d errors!\n", num_errors);
+ }
+ else {
+ printf("PASS!\n");
+ }
+
+ return num_errors;
+} /* comp_matrix_complex */
+
+/*-----------------------------------------------------------------------------
+* Compare two double precision real matrices
+*----------------------------------------------------------------------------*/
+int comp_matrix_double(const double *C1, const double *C2, int M, int N)
+{
+ int i;
+ const double EPISILON = 1e-10;
+ const int NERRORS = 5;
+ int num_errors = 0;
+
+ for (i=0; i<(long)M*N; i++)
+ {
+ double delta = fabs(C1[i] - C2[i]);
+ if (delta > EPISILON*fabs(C1[i])) {
+ if ((num_errors += 1) < NERRORS) {
+ printf("Error [elem:%d]: %e <==> %e\n", i, C1[i], C2[i]);
+ }
+ }
+ }
+
+ if (num_errors > 0) {
+ printf("FAIL with %d errors!\n", num_errors);
+ }
+ else {
+ printf("PASS!\n");
+ }
+
+ return num_errors;
+} /* comp_matrix_double */
+
+/*-----------------------------------------------------------------------------
+* Compare two single precision real matrices
+*----------------------------------------------------------------------------*/
+int comp_matrix(const float *C1, const float *C2, int M, int N)
+{
+ int i;
+ const float EPISILON = 1e-5;
+ const int NERRORS = 5;
+ int num_errors = 0;
+
+ for (i=0; i<(long)M*N; i++)
+ {
+ float delta = fabs(C1[i] - C2[i]);
+
+ if (delta > EPISILON*fabs(C1[i])) {
+ if ((num_errors += 1) < NERRORS) {
+ printf("Error [elem:%d]: %e <==> %e\n", i, C1[i], C2[i]);
+ }
+ }
+ }
+
+ if (num_errors > 0) {
+ printf("FAIL with %d errors!\n", num_errors);
+ }
+ else {
+ printf("PASS!\n");
+ }
+
+ return num_errors;
+}
+
+
+/*-----------------------------------------------------------------------------
+* Compare two double precision complex matrices
+*----------------------------------------------------------------------------*/
+int comp_matrix_double_complex(const double complex *C1, const double complex *C2, int M, int N)
+{
+ int i;
+ const double EPISILON = 1e-10;
+ const int NERRORS = 5;
+ int num_errors = 0;
+
+ for (i=0; i<M*N; i++)
+ {
+ double delta = fabs(cabs(C1[i]) - cabs(C2[i]));
+
+ if (delta > EPISILON*cabs(C1[i])) {
+ if ((num_errors += 1) < NERRORS) {
+ printf("Error [elem:%d]: %f <==> %f\n", i, cabs(C1[i]), cabs(C2[i]));
+ }
+ }
+ }
+
+ if (num_errors > 0) {
+ printf("FAIL with %d errors!\n", num_errors);
+ }
+ else {
+ printf("PASS!\n");
+ }
+
+ return num_errors;
+} /* comp_matrix_double_complex */
+
index 8d1dd3223c3cf29c6f76cb59f1cb875818e24371..0e065326fc17de6b9e0f5fadfc681b888c0ee935 100644 (file)
CFLAGS = -g -O2 -I$(TARGET_ROOTDIR)/usr/include -I$(LINALG_DIR)/packages/ti/linalg
-LIB_DIR = $(LINALG_DIR)/packages/ti/linalg/lib/
+LIB_DIR = ../../lib
LD_FLAGS=-L$(TARGET_ROOTDIR)/lib -L$(TARGET_ROOTDIR)/usr/lib -Wl,-rpath-link,$(TARGET_ROOTDIR)/lib -Wl,-rpath-link,$(TARGET_ROOTDIR)/usr/lib
-BLASLIB = $(LIB_DIR)libcblas_armplusdsp.a -lOpenCL -locl_util -lstdc++ -lrt -lm -lgomp -lpthread
-LAPACKLIB = $(LIB_DIR)libcblaswr.a $(LIB_DIR)liblapack.a $(LIB_DIR)libf2c.a $(LIB_DIR)libcblas_armplusdsp.a -lOpenCL -locl_util -lstdc++ -lrt -lm -lgomp -lpthread
+BLASLIB = $(LIB_DIR)/libcblas_armplusdsp.a -lOpenCL -locl_util -lstdc++ -lrt -lm -lgomp -lpthread
+LAPACKLIB = $(LIB_DIR)/libcblaswr.a $(LIB_DIR)/liblapack.a $(LIB_DIR)/libf2c.a $(LIB_DIR)/libcblas_armplusdsp.a -lOpenCL -locl_util -lstdc++ -lrt -lm -lgomp -lpthread
TUNE_UTILS = ../common/print_header.o ../common/comp_matrix.o
TUNE_UTILS_OBJ = print_header.o comp_matrix.o