Skip to content
Browse files

Provide scalar and piecewise AND

  • Loading branch information...
1 parent 0c581c9 commit e1a66ea1774eed11cdcb807cb470e467f530305f Steve Kerrison committed
View
2 module_matrix/src/matrix.h
@@ -41,7 +41,7 @@
#define MATRIX_ROWS(name) (dim##name[0])
#define MATRIX_COLS(name) (dim##name[1])
-enum matrix_ops { ADD, SUB, MUL, DIV, SDIV, UDIV, RAND, SET, SHR, ASHR, SHL };
+enum matrix_ops { ADD, SUB, MUL, DIV, SDIV, UDIV, RAND, SET, SHR, ASHR, SHL, AND };
int matrix_redim(short dims[4],short rows, short columns);
View
12 module_matrix/src/matrix.xc
@@ -124,6 +124,9 @@ int matrix_sca_op(enum matrix_ops op, int A[], short dimA[2], int S,
case SHL:
matrix_sca_worker_shl(ptA,S,ptC,ptRetval,0,srcSize);
break;
+ case AND:
+ matrix_sca_worker_and(ptA,S,ptC,ptRetval,0,srcSize);
+ break;
default:
break;
}
@@ -164,6 +167,9 @@ int matrix_sca_op(enum matrix_ops op, int A[], short dimA[2], int S,
case SHL:
MATRIX_WORKER_SPAWN(matrix_sca_worker_shl,blockSize,lastBlock,ptA,S,ptC,ptRetval);
break;
+ case AND:
+ MATRIX_WORKER_SPAWN(matrix_sca_worker_and,blockSize,lastBlock,ptA,S,ptC,ptRetval);
+ break;
default:
break;
}
@@ -231,6 +237,9 @@ int matrix_arr_op(enum matrix_ops op, int A[], short dimA[2], int B[], short dim
case UDIV:
matrix_arr_worker_udiv(ptA,ptB,ptC,ptRetval,0,srcSize);
break;
+ case AND:
+ matrix_arr_worker_and(ptA,ptB,ptC,ptRetval,0,srcSize);
+ break;
case RAND: //Fall through to default
case SET: //Still falling...
case SHR: //It's a long way down...
@@ -261,6 +270,9 @@ int matrix_arr_op(enum matrix_ops op, int A[], short dimA[2], int B[], short dim
case UDIV:
MATRIX_WORKER_SPAWN(matrix_arr_worker_udiv,blockSize,lastBlock,ptA,ptB,ptC,ptRetval);
break;
+ case AND:
+ MATRIX_WORKER_SPAWN(matrix_arr_worker_and,blockSize,lastBlock,ptA,ptB,ptC,ptRetval);
+ break;
case RAND: //Fall through to default
case SET: //Still falling...
case SHR: //It's a long way down...
View
25 module_matrix/src/matrix_worker.c
@@ -117,6 +117,19 @@ void matrix_arr_worker_udiv(int ptA, int ptB, int ptC,
return;
}
+void matrix_arr_worker_and(int ptA, int ptB, int ptC,
+ int ptOps, short offset, short len)
+{
+ int *A = (int *)ptA, *B = (int *)ptB, *C = (int *)ptC,
+ *ops = (int *)ptOps, base;
+ for (base = offset; base < offset + len; base += 1)
+ {
+ C[base] = A[base] & B[base];
+ }
+ *ops = len;
+ return;
+}
+
void matrix_sca_worker_add(int ptA, int S, int ptC,
int ptOps, short offset, short len)
{
@@ -239,3 +252,15 @@ void matrix_sca_worker_shl(int ptA, int S, int ptC, int ptOps, short offset, sho
*ops = len;
return;
}
+
+void matrix_sca_worker_and(int ptA, int S, int ptC, int ptOps, short offset, short len)
+{
+ int *A = (int *)ptA, *C = (int *)ptC,
+ *ops = (int *)ptOps, base;
+ for (base = offset; base < offset + len; base += 1)
+ {
+ C[base] = A[base] & S;
+ }
+ *ops = len;
+ return;
+}
View
5 module_matrix/src/matrix_worker.h
@@ -33,6 +33,9 @@ void matrix_arr_worker_div(int ptA, int ptB, int ptC,
void matrix_arr_worker_udiv(int ptA, int ptB, int ptC,
int ptOps, short offset, short len);
+void matrix_arr_worker_and(int ptA, int ptB, int ptC,
+ int ptOps, short offset, short len);
+
/* Scalar ops */
void matrix_sca_worker_add(int ptA, int S, int ptC,
@@ -60,4 +63,6 @@ void matrix_sca_worker_ashr(int ptA, int S, int ptC, int ptOps, short offset, sh
void matrix_sca_worker_shl(int ptA, int S, int ptC, int ptOps, short offset, short len);
+void matrix_sca_worker_and(int ptA, int S, int ptC, int ptOps, short offset, short len);
+
#endif /* MATRIX_WORKER_H_ */

0 comments on commit e1a66ea

Please sign in to comment.
Something went wrong with that request. Please try again.