From 2547163cb283ea642adb488fa0009aa441c0012f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 27 Jan 2015 12:36:44 -0800 Subject: [PATCH] Add erasure package in its full form v1.0 --- Makefile | 6 +- isal | 1 - pkg/storage/erasure/.gitignore | 24 +- pkg/storage/erasure/BUILDDEPS.md | 80 ++ pkg/storage/erasure/CONTRIBUTING.md | 30 + pkg/storage/erasure/{isal => }/LICENSE.INTEL | 0 .../erasure/{isal/LICENSE => LICENSE.MINIO} | 0 pkg/storage/erasure/Makefile | 19 - pkg/storage/erasure/README.md | 9 + .../erasure/{isal => }/RELEASE-NOTES.INTEL | 0 pkg/storage/erasure/RELEASE-NOTES.MINIO | 3 + .../{isal => }/docs/isa-l_open_src_2.10.pdf | 0 pkg/storage/erasure/{isal/src => }/ec-base.c | 4 +- .../erasure/{isal/include => }/ec-base.h | 10 +- .../include/erasure-code.h => ec-code.h} | 2 +- pkg/storage/erasure/{common.h => ec-common.h} | 0 .../include/erasure/types.h => ec-ctypes.h} | 0 pkg/storage/erasure/{decode.c => ec-decode.c} | 4 +- pkg/storage/erasure/{encode.c => ec-encode.c} | 4 +- .../{isal/src => }/ec-highlevel-func.c | 4 +- .../erasure/{isal/src => }/ec-multibinary.asm | 2 +- .../reg-sizes.asm => ec-reg-sizes.asm} | 0 .../include/gf-vect-mul.h => ec-vect-mul.h} | 12 +- .../erasure/{decode.go => erasure_decode.go} | 6 +- .../erasure/{encode.go => erasure_encode.go} | 8 +- pkg/storage/erasure/erasure_yasm_darwin.go | 25 + pkg/storage/erasure/erasure_yasm_linux.go | 25 + pkg/storage/erasure/erasure_yasm_windows.go | 25 + .../{isal/src => }/gf-2vect-dot-prod-avx.asm | 0 .../{isal/src => }/gf-2vect-dot-prod-avx2.asm | 0 .../{isal/src => }/gf-2vect-dot-prod-sse.asm | 0 .../{isal/src => }/gf-3vect-dot-prod-avx.asm | 0 .../{isal/src => }/gf-3vect-dot-prod-avx2.asm | 0 .../{isal/src => }/gf-3vect-dot-prod-sse.asm | 0 .../{isal/src => }/gf-4vect-dot-prod-avx.asm | 0 .../{isal/src => }/gf-4vect-dot-prod-avx2.asm | 0 .../{isal/src => }/gf-4vect-dot-prod-sse.asm | 0 .../{isal/src => }/gf-5vect-dot-prod-avx.asm | 0 .../{isal/src => }/gf-5vect-dot-prod-avx2.asm | 0 .../{isal/src => }/gf-5vect-dot-prod-sse.asm | 0 .../{isal/src => }/gf-6vect-dot-prod-avx.asm | 0 .../{isal/src => }/gf-6vect-dot-prod-avx2.asm | 0 .../{isal/src => }/gf-6vect-dot-prod-sse.asm | 0 .../{isal/src => }/gf-vect-dot-prod-avx.asm | 0 .../{isal/src => }/gf-vect-dot-prod-avx2.asm | 0 .../{isal/src => }/gf-vect-dot-prod-sse.asm | 0 .../{isal/src => }/gf-vect-mul-avx.asm | 0 .../{isal/src => }/gf-vect-mul-sse.asm | 0 pkg/storage/erasure/isal/.gitignore | 22 - pkg/storage/erasure/isal/Makefile | 42 - pkg/storage/erasure/isal/Makefile.nmake | 78 -- pkg/storage/erasure/isal/README.md | 11 - .../erasure/isal/include/erasure/tests.h | 81 -- pkg/storage/erasure/isal/make.inc | 213 ---- pkg/storage/erasure/isal/src/Makefile | 107 -- .../erasure/isal/src/erasure-code-base-perf.c | 168 ---- .../erasure/isal/src/erasure-code-base-test.c | 764 --------------- .../erasure/isal/src/erasure-code-perf.c | 168 ---- .../erasure/isal/src/erasure-code-sse-perf.c | 168 ---- .../erasure/isal/src/erasure-code-sse-test.c | 764 --------------- .../erasure/isal/src/erasure-code-test.c | 763 --------------- .../isal/src/gf-2vect-dot-prod-sse-perf.c | 216 ----- .../isal/src/gf-2vect-dot-prod-sse-test.c | 477 --------- .../isal/src/gf-3vect-dot-prod-sse-perf.c | 246 ----- .../isal/src/gf-3vect-dot-prod-sse-test.c | 583 ----------- .../isal/src/gf-4vect-dot-prod-sse-perf.c | 281 ------ .../isal/src/gf-4vect-dot-prod-sse-test.c | 692 ------------- .../isal/src/gf-5vect-dot-prod-sse-perf.c | 319 ------ .../isal/src/gf-5vect-dot-prod-sse-test.c | 805 ---------------- .../isal/src/gf-6vect-dot-prod-sse-perf.c | 352 ------- .../isal/src/gf-6vect-dot-prod-sse-test.c | 911 ------------------ .../erasure/isal/src/gf-inverse-test.c | 225 ----- .../erasure/isal/src/gf-vect-dot-prod-1tbl.c | 166 ---- .../isal/src/gf-vect-dot-prod-avx-perf.c | 184 ---- .../isal/src/gf-vect-dot-prod-avx-test.c | 525 ---------- .../isal/src/gf-vect-dot-prod-base-test.c | 290 ------ .../erasure/isal/src/gf-vect-dot-prod-perf.c | 184 ---- .../isal/src/gf-vect-dot-prod-sse-perf.c | 184 ---- .../isal/src/gf-vect-dot-prod-sse-test.c | 525 ---------- .../erasure/isal/src/gf-vect-dot-prod-test.c | 525 ---------- .../erasure/isal/src/gf-vect-mul-avx-perf.c | 99 -- .../erasure/isal/src/gf-vect-mul-avx-test.c | 143 --- .../erasure/isal/src/gf-vect-mul-base-test.c | 129 --- .../erasure/isal/src/gf-vect-mul-perf.c | 99 -- .../erasure/isal/src/gf-vect-mul-sse-perf.c | 97 -- .../erasure/isal/src/gf-vect-mul-sse-test.c | 160 --- .../erasure/isal/src/gf-vect-mul-test.c | 142 --- 87 files changed, 246 insertions(+), 11965 deletions(-) delete mode 120000 isal create mode 100644 pkg/storage/erasure/BUILDDEPS.md create mode 100644 pkg/storage/erasure/CONTRIBUTING.md rename pkg/storage/erasure/{isal => }/LICENSE.INTEL (100%) rename pkg/storage/erasure/{isal/LICENSE => LICENSE.MINIO} (100%) delete mode 100644 pkg/storage/erasure/Makefile create mode 100644 pkg/storage/erasure/README.md rename pkg/storage/erasure/{isal => }/RELEASE-NOTES.INTEL (100%) create mode 100644 pkg/storage/erasure/RELEASE-NOTES.MINIO rename pkg/storage/erasure/{isal => }/docs/isa-l_open_src_2.10.pdf (100%) rename pkg/storage/erasure/{isal/src => }/ec-base.c (99%) rename pkg/storage/erasure/{isal/include => }/ec-base.h (99%) rename pkg/storage/erasure/{isal/include/erasure-code.h => ec-code.h} (99%) rename pkg/storage/erasure/{common.h => ec-common.h} (100%) rename pkg/storage/erasure/{isal/include/erasure/types.h => ec-ctypes.h} (100%) rename pkg/storage/erasure/{decode.c => ec-decode.c} (98%) rename pkg/storage/erasure/{encode.c => ec-encode.c} (97%) rename pkg/storage/erasure/{isal/src => }/ec-highlevel-func.c (98%) rename pkg/storage/erasure/{isal/src => }/ec-multibinary.asm (99%) rename pkg/storage/erasure/{isal/include/reg-sizes.asm => ec-reg-sizes.asm} (100%) rename pkg/storage/erasure/{isal/include/gf-vect-mul.h => ec-vect-mul.h} (93%) rename pkg/storage/erasure/{decode.go => erasure_decode.go} (96%) rename pkg/storage/erasure/{encode.go => erasure_encode.go} (96%) create mode 100644 pkg/storage/erasure/erasure_yasm_darwin.go create mode 100644 pkg/storage/erasure/erasure_yasm_linux.go create mode 100644 pkg/storage/erasure/erasure_yasm_windows.go rename pkg/storage/erasure/{isal/src => }/gf-2vect-dot-prod-avx.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-2vect-dot-prod-avx2.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-2vect-dot-prod-sse.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-3vect-dot-prod-avx.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-3vect-dot-prod-avx2.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-3vect-dot-prod-sse.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-4vect-dot-prod-avx.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-4vect-dot-prod-avx2.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-4vect-dot-prod-sse.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-5vect-dot-prod-avx.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-5vect-dot-prod-avx2.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-5vect-dot-prod-sse.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-6vect-dot-prod-avx.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-6vect-dot-prod-avx2.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-6vect-dot-prod-sse.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-vect-dot-prod-avx.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-vect-dot-prod-avx2.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-vect-dot-prod-sse.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-vect-mul-avx.asm (100%) rename pkg/storage/erasure/{isal/src => }/gf-vect-mul-sse.asm (100%) delete mode 100644 pkg/storage/erasure/isal/.gitignore delete mode 100644 pkg/storage/erasure/isal/Makefile delete mode 100644 pkg/storage/erasure/isal/Makefile.nmake delete mode 100644 pkg/storage/erasure/isal/README.md delete mode 100644 pkg/storage/erasure/isal/include/erasure/tests.h delete mode 100644 pkg/storage/erasure/isal/make.inc delete mode 100644 pkg/storage/erasure/isal/src/Makefile delete mode 100644 pkg/storage/erasure/isal/src/erasure-code-base-perf.c delete mode 100644 pkg/storage/erasure/isal/src/erasure-code-base-test.c delete mode 100644 pkg/storage/erasure/isal/src/erasure-code-perf.c delete mode 100644 pkg/storage/erasure/isal/src/erasure-code-sse-perf.c delete mode 100644 pkg/storage/erasure/isal/src/erasure-code-sse-test.c delete mode 100644 pkg/storage/erasure/isal/src/erasure-code-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-inverse-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-dot-prod-1tbl.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-dot-prod-base-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-dot-prod-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-dot-prod-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-mul-avx-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-mul-avx-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-mul-base-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-mul-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-mul-sse-perf.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-mul-sse-test.c delete mode 100644 pkg/storage/erasure/isal/src/gf-vect-mul-test.c diff --git a/Makefile b/Makefile index 91e916562..59042aada 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,7 @@ build-utils: # @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/os/sysctl build-storage: -ifeq ($(ARCH), Darwin) - @$(MAKE) $(MAKE_OPTIONS) arch=osx -C pkg/storage/erasure/isal lib -else - @$(MAKE) $(MAKE_OPTIONS) -C pkg/storage/erasure/isal lib -endif + @godep go generate github.com/minio-io/minio/pkg/storage/erasure @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/storage/erasure build-minioapi: diff --git a/isal b/isal deleted file mode 120000 index 4bb266c4c..000000000 --- a/isal +++ /dev/null @@ -1 +0,0 @@ -pkg/storage/erasure/isal \ No newline at end of file diff --git a/pkg/storage/erasure/.gitignore b/pkg/storage/erasure/.gitignore index c63b20b83..3e4c5920e 100644 --- a/pkg/storage/erasure/.gitignore +++ b/pkg/storage/erasure/.gitignore @@ -1 +1,23 @@ -erasure.test +*.o +*.a +*.so +*~ +*.dSYM +erasure-code-base-test +erasure-code-sse-test +erasure-code-test +gf-2vect-dot-prod-sse-test +gf-3vect-dot-prod-sse-test +gf-4vect-dot-prod-sse-test +gf-5vect-dot-prod-sse-test +gf-6vect-dot-prod-sse-test +gf-inverse-test +gf-vect-dot-prod-avx-test +gf-vect-dot-prod-base-test +gf-vect-dot-prod-sse-test +gf-vect-dot-prod-test +gf-vect-mul-avx-test +gf-vect-mul-base-test +gf-vect-mul-sse-test +gf-vect-mul-test +*.syso \ No newline at end of file diff --git a/pkg/storage/erasure/BUILDDEPS.md b/pkg/storage/erasure/BUILDDEPS.md new file mode 100644 index 000000000..df3770b29 --- /dev/null +++ b/pkg/storage/erasure/BUILDDEPS.md @@ -0,0 +1,80 @@ +## Ubuntu (Kylin) 14.04 +### Build Dependencies +This installation document assumes Ubuntu 14.04 or later on x86-64 platform. + +##### Install YASM + +Erasure depends on Intel ISAL library, ISAL uses Intel AVX2 processor instructions, to compile these files one needs to install ``yasm`` which supports AVX2 instructions. AVX2 support only ended in ``yasm`` from version ``1.2.0``, any version below ``1.2.0`` will throw a build error. + +```sh +$ sudo apt-get install yasm +``` + +##### Install Go 1.4+ +Download Go 1.4+ from [https://golang.org/dl/](https://golang.org/dl/) and extract it into ``${HOME}/local`` and setup ``${HOME}/mygo`` as your project workspace folder. +For example: +```sh +.... Extract and install golang .... + +$ wget https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz +$ mkdir -p ${HOME}/local +$ mkdir -p $HOME/mygo +$ tar -C ${HOME}/local -xzf go1.4.linux-amd64.tar.gz + +.... Export necessary environment variables .... + +$ export PATH=$PATH:${HOME}/local/go/bin +$ export GOROOT=${HOME}/local/go +$ export GOPATH=$HOME/mygo +$ export PATH=$PATH:$GOPATH/bin + +.... Add paths to your bashrc .... + +$ echo "export PATH=$PATH:${HOME}/local/go/bin" >> ${HOME}/.bashrc +$ echo "export GOROOT=${HOME}/local/go" >> ${HOME}/.bashrc +$ echo "export GOPATH=$HOME/mygo" >> ${HOME}/.bashrc +$ echo "export PATH=$PATH:$GOPATH/bin" >> ${HOME}/.bashrc +``` + +## Mac OSX (Yosemite) 10.10 +### Build Dependencies +This installation document assumes Mac OSX Yosemite 10.10 or later on x86-64 platform. + +##### Install brew +```sh +$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + +##### Install Git +```sh +$ brew install git +``` + +##### Install YASM + +Erasure depends on Intel ISAL library, ISAL uses Intel AVX2 processor instructions, to compile these files one needs to install ``yasm`` which supports AVX2 instructions. AVX2 support only ended in ``yasm`` from version ``1.2.0``, any version below ``1.2.0`` will throw a build error. + +```sh +$ brew install yasm +``` + +##### Install Go 1.4+ +On MacOSX ``brew.sh`` is the best way to install golang + +For example: +```sh +.... Install golang using `brew` .... + +$ brew install go +$ mkdir -p $HOME/mygo + +.... Export necessary environment variables .... + +$ export GOPATH=$HOME/mygo +$ export PATH=$PATH:$GOPATH/bin + +.... Add paths to your bashrc .... + +$ echo "export GOPATH=$HOME/mygo" >> ${HOME}/.bashrc +$ echo "export PATH=$PATH:$GOPATH/bin" >> ${HOME}/.bashrc +``` diff --git a/pkg/storage/erasure/CONTRIBUTING.md b/pkg/storage/erasure/CONTRIBUTING.md new file mode 100644 index 000000000..1dfc6a0cb --- /dev/null +++ b/pkg/storage/erasure/CONTRIBUTING.md @@ -0,0 +1,30 @@ +### Setup your Erasure Github Repository +Fork [Erasure upstream](https://github.com/minio-io/erasure/fork) source repository to your own personal repository. Copy the URL and pass it to ``go get`` command. Go uses git to clone a copy into your project workspace folder. +```sh +$ git clone https://github.com/$USER_ID/erasure +$ cd erasure +$ mkdir -p ${GOPATH}/src/github.com/minio-io +$ ln -s ${PWD} $GOPATH/src/github.com/minio-io/ +``` + +### Compiling Erasure from source +```sh +$ go generate +$ go build +``` +### Developer Guidelines +To make the process as seamless as possible, we ask for the following: +* Go ahead and fork the project and make your changes. We encourage pull requests to discuss code changes. + - Fork it + - Create your feature branch (git checkout -b my-new-feature) + - Commit your changes (git commit -am 'Add some feature') + - Push to the branch (git push origin my-new-feature) + - Create new Pull Request +* When you're ready to create a pull request, be sure to: + - Have test cases for the new code. If you have questions about how to do it, please ask in your pull request. + - Run `go fmt` + - Squash your commits into a single commit. `git rebase -i`. It's okay to force update your pull request. + - Make sure `go test -race ./...` and `go build` completes. +* Read [Effective Go](https://github.com/golang/go/wiki/CodeReviewComments) article from Golang project + - `Erasure` project is strictly conformant with Golang style + - if you happen to observe offending code, please feel free to send a pull request diff --git a/pkg/storage/erasure/isal/LICENSE.INTEL b/pkg/storage/erasure/LICENSE.INTEL similarity index 100% rename from pkg/storage/erasure/isal/LICENSE.INTEL rename to pkg/storage/erasure/LICENSE.INTEL diff --git a/pkg/storage/erasure/isal/LICENSE b/pkg/storage/erasure/LICENSE.MINIO similarity index 100% rename from pkg/storage/erasure/isal/LICENSE rename to pkg/storage/erasure/LICENSE.MINIO diff --git a/pkg/storage/erasure/Makefile b/pkg/storage/erasure/Makefile deleted file mode 100644 index 96ffe987b..000000000 --- a/pkg/storage/erasure/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -all: build test -.PHONY: all - -SYSTEM_NAME := $(shell uname -s) - -test: - @godep go test -race -coverprofile=cover.out - -isal/isal-l.a: -ifeq ($(SYSTEM_NAME), Darwin) - @$(MAKE) -C isal arch=osx lib -else - @$(MAKE) -C isal lib -endif -build: isal/isal-l.a - @godep go build - -clean: - @rm -v cover.out diff --git a/pkg/storage/erasure/README.md b/pkg/storage/erasure/README.md new file mode 100644 index 000000000..eed992175 --- /dev/null +++ b/pkg/storage/erasure/README.md @@ -0,0 +1,9 @@ +## Introduction + +Erasure is an open source Golang library written on top of ISAL (Intel Intelligent Storage Library) released under [Apache license v2](./LICENSE) + +### Developers +* [Get Source](./CONTRIBUTING.md) +* [Build Dependencies](./BUILDDEPS.md) +* [Development Workflow](./CONTRIBUTING.md#developer-guidelines) +* [Developer discussions and bugs](https://github.com/Minio-io/erasure/issues) diff --git a/pkg/storage/erasure/isal/RELEASE-NOTES.INTEL b/pkg/storage/erasure/RELEASE-NOTES.INTEL similarity index 100% rename from pkg/storage/erasure/isal/RELEASE-NOTES.INTEL rename to pkg/storage/erasure/RELEASE-NOTES.INTEL diff --git a/pkg/storage/erasure/RELEASE-NOTES.MINIO b/pkg/storage/erasure/RELEASE-NOTES.MINIO new file mode 100644 index 000000000..bf3ed1ece --- /dev/null +++ b/pkg/storage/erasure/RELEASE-NOTES.MINIO @@ -0,0 +1,3 @@ +v1.0 - Erasure Golang Package +============================ +- First release, supports only amd64 or x86-64 architecture \ No newline at end of file diff --git a/pkg/storage/erasure/isal/docs/isa-l_open_src_2.10.pdf b/pkg/storage/erasure/docs/isa-l_open_src_2.10.pdf similarity index 100% rename from pkg/storage/erasure/isal/docs/isa-l_open_src_2.10.pdf rename to pkg/storage/erasure/docs/isa-l_open_src_2.10.pdf diff --git a/pkg/storage/erasure/isal/src/ec-base.c b/pkg/storage/erasure/ec-base.c similarity index 99% rename from pkg/storage/erasure/isal/src/ec-base.c rename to pkg/storage/erasure/ec-base.c index 24529590f..f5bba3101 100644 --- a/pkg/storage/erasure/isal/src/ec-base.c +++ b/pkg/storage/erasure/ec-base.c @@ -30,9 +30,9 @@ #include #include #include // for memset -#include "erasure-code.h" +#include "ec-code.h" #include "ec-base.h" // for GF tables -#include "erasure/types.h" +#include "ec-ctypes.h" uint8_t gf_mul(uint8_t a, uint8_t b) { diff --git a/pkg/storage/erasure/isal/include/ec-base.h b/pkg/storage/erasure/ec-base.h similarity index 99% rename from pkg/storage/erasure/isal/include/ec-base.h rename to pkg/storage/erasure/ec-base.h index f0d6eb9ae..32d70e2c4 100644 --- a/pkg/storage/erasure/isal/include/ec-base.h +++ b/pkg/storage/erasure/ec-base.h @@ -2,7 +2,7 @@ Copyright(c) 2011-2014 Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions + 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. @@ -32,7 +32,7 @@ // Global GF(256) tables #ifndef GF_LARGE_TABLES -uint8_t gff_base[] = { +unsigned char gff_base[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, @@ -61,7 +61,7 @@ uint8_t gff_base[] = { 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x01 }; -uint8_t gflog_base[] = { +unsigned char gflog_base[] = { 0x00, 0xff, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, @@ -90,7 +90,7 @@ uint8_t gflog_base[] = { 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf }; #else -uint8_t gf_mul_table_base[] = { +unsigned char gf_mul_table_base[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -6647,7 +6647,7 @@ uint8_t gf_mul_table_base[] = { 0xc6, 0x39, 0xfe, 0x01, 0x1d, 0xe2 }; -uint8_t gf_inv_table_base[] = { +unsigned char gf_inv_table_base[] = { 0x00, 0x01, 0x8e, 0xf4, 0x47, 0xa7, 0x7a, 0xba, 0xad, 0x9d, 0xdd, 0x98, 0x3d, 0xaa, 0x5d, 0x96, 0xd8, 0x72, 0xc0, 0x58, 0xe0, 0x3e, 0x4c, 0x66, 0x90, 0xde, 0x55, 0x80, 0xa0, 0x83, diff --git a/pkg/storage/erasure/isal/include/erasure-code.h b/pkg/storage/erasure/ec-code.h similarity index 99% rename from pkg/storage/erasure/isal/include/erasure-code.h rename to pkg/storage/erasure/ec-code.h index a4faa36ec..69338ecaa 100644 --- a/pkg/storage/erasure/isal/include/erasure-code.h +++ b/pkg/storage/erasure/ec-code.h @@ -50,7 +50,7 @@ * */ -#include "gf-vect-mul.h" +#include "ec-vect-mul.h" #ifdef __cplusplus extern "C" { diff --git a/pkg/storage/erasure/common.h b/pkg/storage/erasure/ec-common.h similarity index 100% rename from pkg/storage/erasure/common.h rename to pkg/storage/erasure/ec-common.h diff --git a/pkg/storage/erasure/isal/include/erasure/types.h b/pkg/storage/erasure/ec-ctypes.h similarity index 100% rename from pkg/storage/erasure/isal/include/erasure/types.h rename to pkg/storage/erasure/ec-ctypes.h diff --git a/pkg/storage/erasure/decode.c b/pkg/storage/erasure/ec-decode.c similarity index 98% rename from pkg/storage/erasure/decode.c rename to pkg/storage/erasure/ec-decode.c index 3f81cf799..44c46f954 100644 --- a/pkg/storage/erasure/decode.c +++ b/pkg/storage/erasure/ec-decode.c @@ -18,8 +18,8 @@ #include #include -#include -#include "common.h" +#include "ec-code.h" +#include "ec-common.h" static int32_t _minio_src_index_in_error (int r, int32_t *error_index) diff --git a/pkg/storage/erasure/encode.c b/pkg/storage/erasure/ec-encode.c similarity index 97% rename from pkg/storage/erasure/encode.c rename to pkg/storage/erasure/ec-encode.c index 30f0a1820..30d61f73f 100644 --- a/pkg/storage/erasure/encode.c +++ b/pkg/storage/erasure/ec-encode.c @@ -17,8 +17,8 @@ #include #include -#include -#include "common.h" +#include "ec-code.h" +#include "ec-common.h" int32_t minio_init_encoder (int technique, int k, int m, uint8_t **encode_matrix, diff --git a/pkg/storage/erasure/isal/src/ec-highlevel-func.c b/pkg/storage/erasure/ec-highlevel-func.c similarity index 98% rename from pkg/storage/erasure/isal/src/ec-highlevel-func.c rename to pkg/storage/erasure/ec-highlevel-func.c index cc442fed8..ea3c20dc6 100644 --- a/pkg/storage/erasure/isal/src/ec-highlevel-func.c +++ b/pkg/storage/erasure/ec-highlevel-func.c @@ -28,8 +28,8 @@ **********************************************************************/ #include #include -#include "erasure-code.h" -#include "erasure/types.h" +#include "ec-code.h" +#include "ec-ctypes.h" void ec_init_tables(int k, int rows, uint8_t *a, uint8_t *g_tbls) { diff --git a/pkg/storage/erasure/isal/src/ec-multibinary.asm b/pkg/storage/erasure/ec-multibinary.asm similarity index 99% rename from pkg/storage/erasure/isal/src/ec-multibinary.asm rename to pkg/storage/erasure/ec-multibinary.asm index 240f65d71..e37b8f50f 100644 --- a/pkg/storage/erasure/isal/src/ec-multibinary.asm +++ b/pkg/storage/erasure/ec-multibinary.asm @@ -79,7 +79,7 @@ %else -%include "reg-sizes.asm" +%include "ec-reg-sizes.asm" default rel [bits 64] diff --git a/pkg/storage/erasure/isal/include/reg-sizes.asm b/pkg/storage/erasure/ec-reg-sizes.asm similarity index 100% rename from pkg/storage/erasure/isal/include/reg-sizes.asm rename to pkg/storage/erasure/ec-reg-sizes.asm diff --git a/pkg/storage/erasure/isal/include/gf-vect-mul.h b/pkg/storage/erasure/ec-vect-mul.h similarity index 93% rename from pkg/storage/erasure/isal/include/gf-vect-mul.h rename to pkg/storage/erasure/ec-vect-mul.h index eb57f435d..599f8db7f 100644 --- a/pkg/storage/erasure/isal/include/gf-vect-mul.h +++ b/pkg/storage/erasure/ec-vect-mul.h @@ -61,7 +61,7 @@ extern "C" { * @returns 0 pass, other fail */ -int gf_vect_mul_sse(int len, uint8_t *gftbl, void *src, void *dest); +int gf_vect_mul_sse(int len, unsigned char *gftbl, void *src, void *dest); /** @@ -82,7 +82,7 @@ int gf_vect_mul_sse(int len, uint8_t *gftbl, void *src, void *dest); * @returns 0 pass, other fail */ -int gf_vect_mul_avx(int len, uint8_t *gftbl, void *src, void *dest); +int gf_vect_mul_avx(int len, unsigned char *gftbl, void *src, void *dest); /** @@ -105,7 +105,7 @@ int gf_vect_mul_avx(int len, uint8_t *gftbl, void *src, void *dest); * @returns 0 pass, other fail */ -int gf_vect_mul(int len, uint8_t *gftbl, void *src, void *dest); +int gf_vect_mul(int len, unsigned char *gftbl, void *src, void *dest); /** @@ -118,7 +118,7 @@ int gf_vect_mul(int len, uint8_t *gftbl, void *src, void *dest); * @param gftbl Table output. */ -void gf_vect_mul_init(uint8_t c, uint8_t* gftbl); +void gf_vect_mul_init(unsigned char c, unsigned char* gftbl); /** @@ -138,8 +138,8 @@ void gf_vect_mul_init(uint8_t c, uint8_t* gftbl); * @param dest Pointer to destination data array. Must be aligned to 32B. */ -void gf_vect_mul_base(int len, uint8_t *a, uint8_t *src, - uint8_t *dest); +void gf_vect_mul_base(int len, unsigned char *a, unsigned char *src, + unsigned char *dest); #ifdef __cplusplus } diff --git a/pkg/storage/erasure/decode.go b/pkg/storage/erasure/erasure_decode.go similarity index 96% rename from pkg/storage/erasure/decode.go rename to pkg/storage/erasure/erasure_decode.go index 572929fb8..92aa38256 100644 --- a/pkg/storage/erasure/decode.go +++ b/pkg/storage/erasure/erasure_decode.go @@ -18,12 +18,10 @@ package erasure -// #cgo CPPFLAGS: -Iisal/include // #cgo CFLAGS: -O0 // #include -// #include -// -// #include "common.h" +// #include "ec-code.h" +// #include "ec-common.h" import "C" import ( "errors" diff --git a/pkg/storage/erasure/encode.go b/pkg/storage/erasure/erasure_encode.go similarity index 96% rename from pkg/storage/erasure/encode.go rename to pkg/storage/erasure/erasure_encode.go index 270c0157b..849bdbd52 100644 --- a/pkg/storage/erasure/encode.go +++ b/pkg/storage/erasure/erasure_encode.go @@ -18,17 +18,13 @@ package erasure -// #cgo CPPFLAGS: -Iisal/include -// #cgo LDFLAGS: isal/isa-l.a // #cgo CFLAGS: -O0 // #include -// #include -// -// #include "common.h" +// #include "ec-code.h" +// #include "ec-common.h" import "C" import ( "errors" - //"fmt" "unsafe" ) diff --git a/pkg/storage/erasure/erasure_yasm_darwin.go b/pkg/storage/erasure/erasure_yasm_darwin.go new file mode 100644 index 000000000..8187531f5 --- /dev/null +++ b/pkg/storage/erasure/erasure_yasm_darwin.go @@ -0,0 +1,25 @@ +// !build amd64 + +package erasure + +//go:generate yasm -f macho64 ec-multibinary.asm -o ec-multibinary.syso +//go:generate yasm -f macho64 gf-2vect-dot-prod-avx2.asm -o gf-2vect-dot-prod-avx2.syso +//go:generate yasm -f macho64 gf-2vect-dot-prod-avx.asm -o gf-2vect-dot-prod-avx.syso +//go:generate yasm -f macho64 gf-2vect-dot-prod-sse.asm -o gf-2vect-dot-prod-sse.syso +//go:generate yasm -f macho64 gf-3vect-dot-prod-avx2.asm -o gf-3vect-dot-prod-avx2.syso +//go:generate yasm -f macho64 gf-3vect-dot-prod-avx.asm -o gf-3vect-dot-prod-avx.syso +//go:generate yasm -f macho64 gf-3vect-dot-prod-sse.asm -o gf-3vect-dot-prod-sse.syso +//go:generate yasm -f macho64 gf-4vect-dot-prod-avx2.asm -o gf-4vect-dot-prod-avx2.syso +//go:generate yasm -f macho64 gf-4vect-dot-prod-avx.asm -o gf-4vect-dot-prod-avx.syso +//go:generate yasm -f macho64 gf-4vect-dot-prod-sse.asm -o gf-4vect-dot-prod-sse.syso +//go:generate yasm -f macho64 gf-5vect-dot-prod-avx2.asm -o gf-5vect-dot-prod-avx2.syso +//go:generate yasm -f macho64 gf-5vect-dot-prod-avx.asm -o gf-5vect-dot-prod-avx.syso +//go:generate yasm -f macho64 gf-5vect-dot-prod-sse.asm -o gf-5vect-dot-prod-sse.syso +//go:generate yasm -f macho64 gf-6vect-dot-prod-avx2.asm -o gf-6vect-dot-prod-avx2.syso +//go:generate yasm -f macho64 gf-6vect-dot-prod-avx.asm -o gf-6vect-dot-prod-avx.syso +//go:generate yasm -f macho64 gf-6vect-dot-prod-sse.asm -o gf-6vect-dot-prod-sse.syso +//go:generate yasm -f macho64 gf-vect-dot-prod-avx2.asm -o gf-vect-dot-prod-avx2.syso +//go:generate yasm -f macho64 gf-vect-dot-prod-avx.asm -o gf-vect-dot-prod-avx.syso +//go:generate yasm -f macho64 gf-vect-dot-prod-sse.asm -o gf-vect-dot-prod-sse.syso +//go:generate yasm -f macho64 gf-vect-mul-avx.asm -o gf-vect-mul-avx.syso +//go:generate yasm -f macho64 gf-vect-mul-sse.asm -o gf-vect-mul-sse.syso diff --git a/pkg/storage/erasure/erasure_yasm_linux.go b/pkg/storage/erasure/erasure_yasm_linux.go new file mode 100644 index 000000000..b6955a0ab --- /dev/null +++ b/pkg/storage/erasure/erasure_yasm_linux.go @@ -0,0 +1,25 @@ +// !build amd64 + +package erasure + +//go:generate yasm -f elf64 ec-multibinary.asm -o ec-multibinary.syso +//go:generate yasm -f elf64 gf-2vect-dot-prod-avx2.asm -o gf-2vect-dot-prod-avx2.syso +//go:generate yasm -f elf64 gf-2vect-dot-prod-avx.asm -o gf-2vect-dot-prod-avx.syso +//go:generate yasm -f elf64 gf-2vect-dot-prod-sse.asm -o gf-2vect-dot-prod-sse.syso +//go:generate yasm -f elf64 gf-3vect-dot-prod-avx2.asm -o gf-3vect-dot-prod-avx2.syso +//go:generate yasm -f elf64 gf-3vect-dot-prod-avx.asm -o gf-3vect-dot-prod-avx.syso +//go:generate yasm -f elf64 gf-3vect-dot-prod-sse.asm -o gf-3vect-dot-prod-sse.syso +//go:generate yasm -f elf64 gf-4vect-dot-prod-avx2.asm -o gf-4vect-dot-prod-avx2.syso +//go:generate yasm -f elf64 gf-4vect-dot-prod-avx.asm -o gf-4vect-dot-prod-avx.syso +//go:generate yasm -f elf64 gf-4vect-dot-prod-sse.asm -o gf-4vect-dot-prod-sse.syso +//go:generate yasm -f elf64 gf-5vect-dot-prod-avx2.asm -o gf-5vect-dot-prod-avx2.syso +//go:generate yasm -f elf64 gf-5vect-dot-prod-avx.asm -o gf-5vect-dot-prod-avx.syso +//go:generate yasm -f elf64 gf-5vect-dot-prod-sse.asm -o gf-5vect-dot-prod-sse.syso +//go:generate yasm -f elf64 gf-6vect-dot-prod-avx2.asm -o gf-6vect-dot-prod-avx2.syso +//go:generate yasm -f elf64 gf-6vect-dot-prod-avx.asm -o gf-6vect-dot-prod-avx.syso +//go:generate yasm -f elf64 gf-6vect-dot-prod-sse.asm -o gf-6vect-dot-prod-sse.syso +//go:generate yasm -f elf64 gf-vect-dot-prod-avx2.asm -o gf-vect-dot-prod-avx2.syso +//go:generate yasm -f elf64 gf-vect-dot-prod-avx.asm -o gf-vect-dot-prod-avx.syso +//go:generate yasm -f elf64 gf-vect-dot-prod-sse.asm -o gf-vect-dot-prod-sse.syso +//go:generate yasm -f elf64 gf-vect-mul-avx.asm -o gf-vect-mul-avx.syso +//go:generate yasm -f elf64 gf-vect-mul-sse.asm -o gf-vect-mul-sse.syso diff --git a/pkg/storage/erasure/erasure_yasm_windows.go b/pkg/storage/erasure/erasure_yasm_windows.go new file mode 100644 index 000000000..97fecd5e6 --- /dev/null +++ b/pkg/storage/erasure/erasure_yasm_windows.go @@ -0,0 +1,25 @@ +// !build amd64 + +package erasure + +//go:generate yasm -f win64 ec-multibinary.asm -o ec-multibinary.syso +//go:generate yasm -f win64 gf-2vect-dot-prod-avx2.asm -o gf-2vect-dot-prod-avx2.syso +//go:generate yasm -f win64 gf-2vect-dot-prod-avx.asm -o gf-2vect-dot-prod-avx.syso +//go:generate yasm -f win64 gf-2vect-dot-prod-sse.asm -o gf-2vect-dot-prod-sse.syso +//go:generate yasm -f win64 gf-3vect-dot-prod-avx2.asm -o gf-3vect-dot-prod-avx2.syso +//go:generate yasm -f win64 gf-3vect-dot-prod-avx.asm -o gf-3vect-dot-prod-avx.syso +//go:generate yasm -f win64 gf-3vect-dot-prod-sse.asm -o gf-3vect-dot-prod-sse.syso +//go:generate yasm -f win64 gf-4vect-dot-prod-avx2.asm -o gf-4vect-dot-prod-avx2.syso +//go:generate yasm -f win64 gf-4vect-dot-prod-avx.asm -o gf-4vect-dot-prod-avx.syso +//go:generate yasm -f win64 gf-4vect-dot-prod-sse.asm -o gf-4vect-dot-prod-sse.syso +//go:generate yasm -f win64 gf-5vect-dot-prod-avx2.asm -o gf-5vect-dot-prod-avx2.syso +//go:generate yasm -f win64 gf-5vect-dot-prod-avx.asm -o gf-5vect-dot-prod-avx.syso +//go:generate yasm -f win64 gf-5vect-dot-prod-sse.asm -o gf-5vect-dot-prod-sse.syso +//go:generate yasm -f win64 gf-6vect-dot-prod-avx2.asm -o gf-6vect-dot-prod-avx2.syso +//go:generate yasm -f win64 gf-6vect-dot-prod-avx.asm -o gf-6vect-dot-prod-avx.syso +//go:generate yasm -f win64 gf-6vect-dot-prod-sse.asm -o gf-6vect-dot-prod-sse.syso +//go:generate yasm -f win64 gf-vect-dot-prod-avx2.asm -o gf-vect-dot-prod-avx2.syso +//go:generate yasm -f win64 gf-vect-dot-prod-avx.asm -o gf-vect-dot-prod-avx.syso +//go:generate yasm -f win64 gf-vect-dot-prod-sse.asm -o gf-vect-dot-prod-sse.syso +//go:generate yasm -f win64 gf-vect-mul-avx.asm -o gf-vect-mul-avx.syso +//go:generate yasm -f win64 gf-vect-mul-sse.asm -o gf-vect-mul-sse.syso diff --git a/pkg/storage/erasure/isal/src/gf-2vect-dot-prod-avx.asm b/pkg/storage/erasure/gf-2vect-dot-prod-avx.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-2vect-dot-prod-avx.asm rename to pkg/storage/erasure/gf-2vect-dot-prod-avx.asm diff --git a/pkg/storage/erasure/isal/src/gf-2vect-dot-prod-avx2.asm b/pkg/storage/erasure/gf-2vect-dot-prod-avx2.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-2vect-dot-prod-avx2.asm rename to pkg/storage/erasure/gf-2vect-dot-prod-avx2.asm diff --git a/pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse.asm b/pkg/storage/erasure/gf-2vect-dot-prod-sse.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse.asm rename to pkg/storage/erasure/gf-2vect-dot-prod-sse.asm diff --git a/pkg/storage/erasure/isal/src/gf-3vect-dot-prod-avx.asm b/pkg/storage/erasure/gf-3vect-dot-prod-avx.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-3vect-dot-prod-avx.asm rename to pkg/storage/erasure/gf-3vect-dot-prod-avx.asm diff --git a/pkg/storage/erasure/isal/src/gf-3vect-dot-prod-avx2.asm b/pkg/storage/erasure/gf-3vect-dot-prod-avx2.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-3vect-dot-prod-avx2.asm rename to pkg/storage/erasure/gf-3vect-dot-prod-avx2.asm diff --git a/pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse.asm b/pkg/storage/erasure/gf-3vect-dot-prod-sse.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse.asm rename to pkg/storage/erasure/gf-3vect-dot-prod-sse.asm diff --git a/pkg/storage/erasure/isal/src/gf-4vect-dot-prod-avx.asm b/pkg/storage/erasure/gf-4vect-dot-prod-avx.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-4vect-dot-prod-avx.asm rename to pkg/storage/erasure/gf-4vect-dot-prod-avx.asm diff --git a/pkg/storage/erasure/isal/src/gf-4vect-dot-prod-avx2.asm b/pkg/storage/erasure/gf-4vect-dot-prod-avx2.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-4vect-dot-prod-avx2.asm rename to pkg/storage/erasure/gf-4vect-dot-prod-avx2.asm diff --git a/pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse.asm b/pkg/storage/erasure/gf-4vect-dot-prod-sse.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse.asm rename to pkg/storage/erasure/gf-4vect-dot-prod-sse.asm diff --git a/pkg/storage/erasure/isal/src/gf-5vect-dot-prod-avx.asm b/pkg/storage/erasure/gf-5vect-dot-prod-avx.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-5vect-dot-prod-avx.asm rename to pkg/storage/erasure/gf-5vect-dot-prod-avx.asm diff --git a/pkg/storage/erasure/isal/src/gf-5vect-dot-prod-avx2.asm b/pkg/storage/erasure/gf-5vect-dot-prod-avx2.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-5vect-dot-prod-avx2.asm rename to pkg/storage/erasure/gf-5vect-dot-prod-avx2.asm diff --git a/pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse.asm b/pkg/storage/erasure/gf-5vect-dot-prod-sse.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse.asm rename to pkg/storage/erasure/gf-5vect-dot-prod-sse.asm diff --git a/pkg/storage/erasure/isal/src/gf-6vect-dot-prod-avx.asm b/pkg/storage/erasure/gf-6vect-dot-prod-avx.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-6vect-dot-prod-avx.asm rename to pkg/storage/erasure/gf-6vect-dot-prod-avx.asm diff --git a/pkg/storage/erasure/isal/src/gf-6vect-dot-prod-avx2.asm b/pkg/storage/erasure/gf-6vect-dot-prod-avx2.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-6vect-dot-prod-avx2.asm rename to pkg/storage/erasure/gf-6vect-dot-prod-avx2.asm diff --git a/pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse.asm b/pkg/storage/erasure/gf-6vect-dot-prod-sse.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse.asm rename to pkg/storage/erasure/gf-6vect-dot-prod-sse.asm diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx.asm b/pkg/storage/erasure/gf-vect-dot-prod-avx.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx.asm rename to pkg/storage/erasure/gf-vect-dot-prod-avx.asm diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx2.asm b/pkg/storage/erasure/gf-vect-dot-prod-avx2.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx2.asm rename to pkg/storage/erasure/gf-vect-dot-prod-avx2.asm diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse.asm b/pkg/storage/erasure/gf-vect-dot-prod-sse.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse.asm rename to pkg/storage/erasure/gf-vect-dot-prod-sse.asm diff --git a/pkg/storage/erasure/isal/src/gf-vect-mul-avx.asm b/pkg/storage/erasure/gf-vect-mul-avx.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-vect-mul-avx.asm rename to pkg/storage/erasure/gf-vect-mul-avx.asm diff --git a/pkg/storage/erasure/isal/src/gf-vect-mul-sse.asm b/pkg/storage/erasure/gf-vect-mul-sse.asm similarity index 100% rename from pkg/storage/erasure/isal/src/gf-vect-mul-sse.asm rename to pkg/storage/erasure/gf-vect-mul-sse.asm diff --git a/pkg/storage/erasure/isal/.gitignore b/pkg/storage/erasure/isal/.gitignore deleted file mode 100644 index 8a225ebd6..000000000 --- a/pkg/storage/erasure/isal/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -*.o -*.a -*.so -*~ -*.dSYM -erasure-code-base-test -erasure-code-sse-test -erasure-code-test -gf-2vect-dot-prod-sse-test -gf-3vect-dot-prod-sse-test -gf-4vect-dot-prod-sse-test -gf-5vect-dot-prod-sse-test -gf-6vect-dot-prod-sse-test -gf-inverse-test -gf-vect-dot-prod-avx-test -gf-vect-dot-prod-base-test -gf-vect-dot-prod-sse-test -gf-vect-dot-prod-test -gf-vect-mul-avx-test -gf-vect-mul-base-test -gf-vect-mul-sse-test -gf-vect-mul-test diff --git a/pkg/storage/erasure/isal/Makefile b/pkg/storage/erasure/isal/Makefile deleted file mode 100644 index 20625e7fe..000000000 --- a/pkg/storage/erasure/isal/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -######################################################################## -# Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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. -######################################################################## - - -units = src - -default: lib - -include $(foreach unit,$(units), $(unit)/Makefile) - -# Override individual lib names to make one inclusive library. -lib_name := isa-l.a - -include make.inc - -VPATH = $(units) include diff --git a/pkg/storage/erasure/isal/Makefile.nmake b/pkg/storage/erasure/isal/Makefile.nmake deleted file mode 100644 index 70af27695..000000000 --- a/pkg/storage/erasure/isal/Makefile.nmake +++ /dev/null @@ -1,78 +0,0 @@ -######################################################################## -# Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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. -######################################################################## - -objs = src\ec-base.obj src\ec-highlevel-func.obj src\ec-multisrcary.obj src\gf-2vect-dot-prod-avx.obj src\gf-2vect-dot-prod-avx2.obj src\gf-2vect-dot-prod-sse.obj src\gf-3vect-dot-prod-avx.obj src\gf-3vect-dot-prod-avx2.obj src\gf-3vect-dot-prod-sse.obj src\gf-4vect-dot-prod-avx.obj src\gf-4vect-dot-prod-avx2.obj src\gf-4vect-dot-prod-sse.obj src\gf-5vect-dot-prod-avx.obj src\gf-5vect-dot-prod-avx2.obj src\gf-5vect-dot-prod-sse.obj src\gf-6vect-dot-prod-avx.obj src\gf-6vect-dot-prod-avx2.obj src\gf-6vect-dot-prod-sse.obj src\gf-vect-dot-prod-avx.obj src\gf-vect-dot-prod-avx2.obj src\gf-vect-dot-prod-sse.obj src\gf-vect-mul-avx.obj src\gf-vect-mul-sse.obj - -libpath = c:\openssl\lib #set to ossl path for tests -lisrcc = c:\openssl\include -zlibpath = c:\zlib\lib -zlisrcc = c:\zlib\include -INCLUDES = -Isrc -Iinclude -I$(lisrcc) -I$(zlisrcc) -CFLAGS = -O2 -D ZLIB-WINAPI -D NDEBUG /nologo -D-USE-MATH-DEFINES -Qstd=c99 $(INCLUDES) $(D) -AFLAGS = -f win64 $(INCLUDES) $(D) -CC = icl -AS = yasm - -lib: src isa-l.lib - -src: ; -mkdir $@ - -isa-l.lib: $(objs) - lib -out:$@ $? - -{erasure-code}.c.obj: - $(CC) $(CFLAGS) /c -Fo$@ $? -{erasure-code}.asm.obj: - $(AS) $(AFLAGS) -o $@ $? - - - -.obj.exe: - link /out:$@ /nologo /libpath:$(libpath) /libpath:$(zlibpath) isa-l.lib $? - -# Unit tests -tests = erasure-code-base-test.exe erasure-code-sse-test.exe erasure-code-test.exe gf-2vect-dot-prod-sse-test.exe gf-3vect-dot-prod-sse-test.exe gf-4vect-dot-prod-sse-test.exe gf-5vect-dot-prod-sse-test.exe gf-6vect-dot-prod-sse-test.exe gf-inverse-test.exe gf-vect-dot-prod-avx-test.exe gf-vect-dot-prod-base-test.exe gf-vect-dot-prod-sse-test.exe gf-vect-dot-prod-test.exe gf-vect-mul-avx-test.exe gf-vect-mul-base-test.exe gf-vect-mul-sse-test.exe gf-vect-mul-test.exe - -tests: lib $(tests) -$(tests): $(@B).obj - -# Performance tests -perfs = erasure-code-base-perf.exe erasure-code-perf.exe erasure-code-sse-perf.exe gf-2vect-dot-prod-sse-perf.exe gf-3vect-dot-prod-sse-perf.exe gf-4vect-dot-prod-sse-perf.exe gf-5vect-dot-prod-sse-perf.exe gf-6vect-dot-prod-sse-perf.exe gf-vect-dot-prod-1tbl.exe gf-vect-dot-prod-avx-perf.exe gf-vect-dot-prod-perf.exe gf-vect-dot-prod-sse-perf.exe gf-vect-mul-avx-perf.exe gf-vect-mul-perf.exe gf-vect-mul-sse-perf.exe - -perfs: lib $(perfs) -$(perfs): $(@B).obj - -clean: - -if exist *.obj del *.obj - -if exist src\*.obj del src\*.obj - -if exist *.exe del *.exe - -if exist isa-l.lib del isa-l.lib - -zlib.lib: -libeay32.lib: diff --git a/pkg/storage/erasure/isal/README.md b/pkg/storage/erasure/isal/README.md deleted file mode 100644 index b7d5a6daa..000000000 --- a/pkg/storage/erasure/isal/README.md +++ /dev/null @@ -1,11 +0,0 @@ -- Install 'build-essential' - -~~~ - # apt-get install build-essential -y -~~~ - -- Install 'yasm' - -~~~ - # apt-get install yasm -y -~~~ diff --git a/pkg/storage/erasure/isal/include/erasure/tests.h b/pkg/storage/erasure/isal/include/erasure/tests.h deleted file mode 100644 index bdf7081c9..000000000 --- a/pkg/storage/erasure/isal/include/erasure/tests.h +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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. -**********************************************************************/ - - -#ifndef __ERASURE_TESTS_H -#define __ERASURE_TESTS_H - -#ifdef __cplusplus -extern "C" { -#endif - -// Use sys/time.h functions for time - -#include - -struct perf{ - struct timeval tv; -}; - - -inline int perf_start(struct perf *p) -{ - return gettimeofday(&(p->tv), 0); -} -inline int perf_stop(struct perf *p) -{ - return gettimeofday(&(p->tv), 0); -} - -inline void perf_print(struct perf stop, struct perf start, long long dsize) -{ - long long secs = stop.tv.tv_sec - start.tv.tv_sec; - long long usecs = secs * 1000000 + stop.tv.tv_usec - start.tv.tv_usec; - - printf("runtime = %10lld usecs", usecs); - if (dsize != 0) { -#if 1 // not bug in printf for 32-bit - printf(", bandwidth %lld MB in %.4f sec = %.2f MB/s\n", dsize/(1024*1024), - ((double) usecs)/1000000, ((double) dsize) / (double)usecs); -#else - printf(", bandwidth %lld MB ", dsize/(1024*1024)); - printf("in %.4f sec ",(double)usecs/1000000); - printf("= %.2f MB/s\n", (double)dsize/usecs); -#endif - } - else - printf("\n"); -} - - -#ifdef __cplusplus -} -#endif - -#endif // __ERASURE_TESTS_H diff --git a/pkg/storage/erasure/isal/make.inc b/pkg/storage/erasure/isal/make.inc deleted file mode 100644 index 29c93e384..000000000 --- a/pkg/storage/erasure/isal/make.inc +++ /dev/null @@ -1,213 +0,0 @@ -######################################################################## -# Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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. -######################################################################## - - -# Makefile include for optimized libraries -# make targets: -# lib - build library of optimized functions -# slib - build shared library -# test - run unit tests of functions -# perf - run performance tests -# sim - run on simulator -# trace - get simulator trace -# clean - remove object files - -CC = gcc -AS = yasm -SIM = sde $(SIMFLAGS) -- - -DEBUG = -g -DEBUG_yasm = -g dwarf2 -DEBUG_nasm = -g - -# Default arch= build options -CFLAGS_gcc = -Wall -ASFLAGS_ = -f elf64 -ARFLAGS_ = cr $@ -STRIP_gcc = strip -d -R .comment $@ -STRIP_clang = strip -d $@ - -# arch=32 build options -ASFLAGS_32 = -f elf32 -CFLAGS_32 = -m32 -ARFLAGS_32 = cr $@ - -# arch=win64 build options -ASFLAGS_win64 = -f win64 -CFLAGS_icl = -Qstd=c99 -ARFLAGS_win64 = -out:$@ - -# arch=osx build options -ASFLAGS_osx = -f macho64 -ARFLAGS_osx = -r $@ -STRIP_gcc = strip -d $@ - -# arch=mingw build options -ASFLAGS_mingw = -f win64 -ARFLAGS_mingw = cr $@ -lsrcmingw = $(lsrc) -unit_testsmingw = $(unit_tests) -examplesmingw = $(examples) -perf_testsmingw = $(perf_tests) - -ifeq ($(arch),mingw) - CC=x86_64-w64-mingw32-gcc - AR=x86_64-w64-mingw32-ar - LDFLAGS = -Wl,--force-exe-suffix -endif - - -INCLUDE = $(patsubst %,-I%,$(subst :, ,$(VPATH))) -CFLAGS = $(CFLAGS_$(arch)) $(CFLAGS_$(CC)) $(DEBUG) -O2 $(DEFINES) $(INCLUDE) -ASFLAGS = $(ASFLAGS_$(arch)) $(ASFLAGS_$(CC)) $(DEBUG_$(AS)) $(DEFINES) $(INCLUDE) -ARFLAGS = $(ARFLAGS_$(arch)) -DEFINES += $(addprefix -D , $D) - -O = src -lobj += $(patsubst %.c,%.o,$(patsubst %.asm,%.o,$(lsrc$(arch)))) -objs = $(addprefix $(O)/,$(lobj)) - - -lib_name ?= isa-l.a -default: lib - -# Defaults for windows build -ifeq ($(arch),win64) - AR=lib - CC=cl - OUTPUT_OPTION = -Fo$@ - DEBUG= - lib_name := $(basename $(lib_name)).lib -endif -lsrcwin64 = $(lsrc) -lsrcosx = $(lsrc) -unit_testswin64 = $(unit_tests) -unit_testsosx = $(unit_tests) -exampleswin64 = $(examples) -examplesosx = $(examples) -perf_testswin64 = $(perf_tests) -perf_testsosx = $(perf_tests) - -# Build and run unit tests, performance tests, etc. -all_tests = $(sort $(perf_tests$(arch)) $(unit_tests$(arch)) $(examples$(arch)) $(other_tests)) - -$(sort $(unit_tests$(arch))): % : %.c $(tsrc$(arch)) $(lib_name) -$(sort $(perf_tests$(arch))): % : %.c $(lib_name) -$(sort $(examples$(arch))): % : %.c $(lib_name) -$(sort $(other_tests)): % : %.c $(lib_name) - -sim test trace: $(addsuffix .run,$(unit_tests$(arch))) -perf: $(addsuffix .run,$(perf_tests$(arch))) -ex: $(examples$(arch)) -all: lib $(all_tests) -other: $(other_tests) -tests: $(unit_tests$(arch)) -perfs: $(perf_tests$(arch)) -test perf: SIM= -trace: SIMFLAGS = -debugtrace -test sim: - @echo Finished running tests - -$(objs): | $(O) -$(O): ; mkdir -p $(O) - - -# Build rule to run tests -%.run: % - $(SIM) $(@D)/$< - @echo Completed run: $< - -# Other build rules -msg = $(if $(DEBUG),DEBUG) $(patsubst 32,32-bit,$(arch)) $D - -$(O)/%.o: %.asm - @echo " ---> Building $< $(msg)" - @$(AS) $(ASFLAGS) -o $@ $< - -$(O)/%.o %.o: %.c - @echo " ---> Building $< $(msg)" - @$(COMPILE.c) $(OUTPUT_OPTION) $< - -$(all_tests): - @echo " ---> Building Test $@ $(msg)" - @$(LINK.o) $(CFLAGS) $^ $(LDLIBS) -o $@ - - -# Target to build lib files -lib: $(lib_name) -ifneq ($(lib_debug),1) - $(lib_name): DEBUG_$(AS)= # Don't put debug symbols in the lib - $(lib_name): DEBUG= - $(lib_name): DEFINES+=-D NDEBUG -endif -ifeq ($(lib_debug),1) - DEBUG+=-D DEBUG # Define DEBUG for macros -endif - -#lib $(lib_name): $(lib_name)(${objs}) -$(lib_name): $(objs) - @echo " ---> Creating Lib $@" - @$(AR) $(ARFLAGS) $^ - @$(STRIP_$(CC)) $^ - -# Target for shared lib -so_lib_name ?= $(basename $(lib_name)).so -slib: $(so_lib_name) -aobjs += $(addprefix $(O)/,$(patsubst %.asm,%.o,$(filter %.asm,$(lsrc$(arch))))) -shared_objs += $(addprefix $(O)/shared_ver_,$(patsubst %.c,%.o,$(filter %.c,$(lsrc$(arch))))) - -$(O)/shared_ver_%.o: %.c - @echo " ---> Building shared $< $(msg)" - @$(COMPILE.c) $(OUTPUT_OPTION) $< - -ifneq ($(lib_debug),1) - $(so_lib_name): DEBUG_$(AS)= - $(so_lib_name): DEBUG= - $(so_lib_name): DEFINES+=-D NDEBUG -endif - -$(shared_objs): CFLAGS += -fPIC -$(shared_objs) $(aobjs): | $(O) -$(so_lib_name): $(shared_objs) $(aobjs) - @echo " ---> Creating Shared Lib $@" - @$(CC) $(CFLAGS) -shared $(LDFLAGS) -o $@ $^ - @$(STRIP_$(CC)) $^ - -# Collect performance data -rpt_name = perf_report_$(shell uname -n)_$(shell date +%y%m%d).perf - -perf_report: - echo Results for $(rpt_name) >> $(rpt_name) - $(MAKE) -k perf | tee -a $(rpt_name) - @echo Summary: - -grep runtime $(rpt_name) - -clean: - @echo Cleaning up - @$(RM) -r $(O)/*.o *.a $(all_tests) $(lib_name) $(so_lib_name) diff --git a/pkg/storage/erasure/isal/src/Makefile b/pkg/storage/erasure/isal/src/Makefile deleted file mode 100644 index 915057eef..000000000 --- a/pkg/storage/erasure/isal/src/Makefile +++ /dev/null @@ -1,107 +0,0 @@ -######################################################################## -# Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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. -######################################################################## - - -lib_name := erasure_code.a - -lsrc += ec-highlevel-func.c \ - ec-base.c \ - gf-vect-mul-sse.asm \ - gf-vect-mul-avx.asm \ - gf-vect-dot-prod-sse.asm \ - gf-vect-dot-prod-avx.asm \ - gf-vect-dot-prod-avx2.asm \ - gf-2vect-dot-prod-sse.asm \ - gf-3vect-dot-prod-sse.asm \ - gf-4vect-dot-prod-sse.asm \ - gf-5vect-dot-prod-sse.asm \ - gf-6vect-dot-prod-sse.asm \ - gf-2vect-dot-prod-avx.asm \ - gf-3vect-dot-prod-avx.asm \ - gf-4vect-dot-prod-avx.asm \ - gf-5vect-dot-prod-avx.asm \ - gf-6vect-dot-prod-avx.asm \ - gf-2vect-dot-prod-avx2.asm \ - gf-3vect-dot-prod-avx2.asm \ - gf-4vect-dot-prod-avx2.asm \ - gf-5vect-dot-prod-avx2.asm \ - gf-6vect-dot-prod-avx2.asm \ - ec-multibinary.asm - -lsrc32 += ec-highlevel-func.c ec-multibinary.asm ec-base.c - -unit_tests32 += erasure-code-base-test erasure-code-test \ - gf-vect-mul-test gf-vect-mul-base-test \ - gf-vect-dot-prod-base-test gf-vect-dot-prod-test - -perf_tests32 += gf-vect-mul-perf gf-vect-dot-prod-perf erasure-code-perf \ - erasure-code-base-perf gf-vect-dot-prod-1tbl - -extern_hdrs += erasure-code.h ec_base.h gf-vect-mul.h \ - erasure/tests.h erausre/types.h - -unit_tests += gf-vect-mul-test \ - gf-vect-mul-sse-test \ - gf-vect-mul-avx-test \ - gf-vect-mul-base-test \ - gf-vect-dot-prod-sse-test \ - gf-vect-dot-prod-avx-test \ - gf-2vect-dot-prod-sse-test \ - gf-3vect-dot-prod-sse-test \ - gf-4vect-dot-prod-sse-test \ - gf-5vect-dot-prod-sse-test \ - gf-6vect-dot-prod-sse-test \ - gf-inverse-test \ - gf-vect-dot-prod-base-test \ - gf-vect-dot-prod-test \ - erasure-code-test \ - erasure-code-base-test \ - erasure-code-sse-test - -perf_tests += gf-vect-mul-perf \ - gf-vect-mul-sse-perf \ - gf-vect-mul-avx-perf \ - gf-vect-dot-prod-sse-perf \ - gf-vect-dot-prod-avx-perf \ - gf-2vect-dot-prod-sse-perf \ - gf-3vect-dot-prod-sse-perf \ - gf-4vect-dot-prod-sse-perf \ - gf-5vect-dot-prod-sse-perf \ - gf-6vect-dot-prod-sse-perf \ - gf-vect-dot-prod-perf \ - gf-vect-dot-prod-1tbl \ - erasure-code-perf \ - erasure-code-base-perf \ - erasure-code-sse-perf - -other_src += reg-sizes.asm - -VPATH = .. ../include - --include ../make.inc diff --git a/pkg/storage/erasure/isal/src/erasure-code-base-perf.c b/pkg/storage/erasure/isal/src/erasure-code-base-perf.c deleted file mode 100644 index 020becafa..000000000 --- a/pkg/storage/erasure/isal/src/erasure-code-base-perf.c +++ /dev/null @@ -1,168 +0,0 @@ -/********************************************************************** - COPYRIGHT(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 32 -# define TEST_LEN(m) ((128*1024 / m) & ~(64-1)) -# define TEST_LOOPS(m) (100*m) -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 32 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64-1)) -# define TEST_LOOPS(m) (10) -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS(m) 1000 -# endif -# endif -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i, j, rtest, m, k, nerrs, r; - void *buf; - u8 *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; - u8 g_tbls[KMAX * TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; - u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - struct perf start, stop; - - // Pick test parameters - m = 14; - k = 10; - nerrs = 4; - const u8 err_list[] = {2, 4, 5, 7}; - - printf("erasure_code_base_perf: %dx%d %d\n", m, TEST_LEN(m), nerrs); - - if (m > MMAX || k > KMAX || nerrs > (m - k)){ - printf(" Input test parameter error\n"); - return -1; - } - - memcpy(src_err_list, err_list, nerrs); - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0; i < nerrs; i++) - src_in_err[src_err_list[i]] = 1; - - // Allocate the arrays - for (i = 0; i < m; i++) { - if (posix_memalign(&buf, 64, TEST_LEN(m))) { - printf("alloc error: Fail\n"); - return -1; - } - buffs[i] = buf; - } - - for (i = 0; i < (m - k); i++) { - if (posix_memalign(&buf, 64, TEST_LEN(m))) { - printf("alloc error: Fail\n"); - return -1; - } - temp_buffs[i] = buf; - } - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN(m); j++) - buffs[i][j] = rand(); - - gf_gen_rs_matrix(a, m, k); - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data_base(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - - // Start encode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Make parity vects - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data_base(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - } - perf_stop(&stop); - printf("erasure_code_base_encode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (m) * rtest); - - // Start decode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - recov[i] = buffs[r]; - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix(b, d, k) < 0) { - printf("BAD MATRIX\n"); - return -1; - } - - for (i = 0; i < nerrs; i++) - for (j = 0; j < k; j++) - c[k * i + j] = d[k * src_err_list[i] + j]; - - // Recover data - ec_init_tables(k, nerrs, c, g_tbls); - ec_encode_data_base(TEST_LEN(m), k, nerrs, g_tbls, recov, temp_buffs); - } - perf_stop(&stop); - - for (i = 0; i < nerrs; i++) { - if (0 != memcmp(temp_buffs[i], buffs[src_err_list[i]], TEST_LEN(m))) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - return -1; - } - } - - printf("erasure_code_base_decode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (k + nerrs) * rtest); - - printf("done all: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/erasure-code-base-test.c b/pkg/storage/erasure/isal/src/erasure-code-base-test.c deleted file mode 100644 index f16a29d64..000000000 --- a/pkg/storage/erasure/isal/src/erasure-code-base-test.c +++ /dev/null @@ -1,764 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) - -#ifndef TEST_SOURCES -# define TEST_SOURCES 127 -#endif -#ifndef RANDOMS -# define RANDOMS 50 -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -#define EFENCE_TEST_MIN_SIZE 16 - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -#ifndef TEST_SEED -#define TEST_SEED 11 -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -// Generate Random errors -static void gen_err_list(unsigned char *src_err_list, - unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs, int k, int m) -{ - int i, err; - int nerrs = 0, nsrcerrs = 0; - - for (i = 0, nerrs = 0, nsrcerrs = 0; i < m && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) { - src_err_list[nerrs++] = i; - if (i < k) { - nsrcerrs++; - } - } - } - if (nerrs == 0) { // should have at least one error - while ((err = (rand() % KMAX)) >= m) ; - src_err_list[nerrs++] = err; - src_in_err[err] = 1; - if (err < k) - nsrcerrs = 1; - } - *pnerrs = nerrs; - *pnsrcerrs = nsrcerrs; - return; -} - -#define NO_INVERT_MATRIX -2 -// Generate decode matrix from encode matrix -static int gf_gen_decode_matrix(unsigned char *encode_matrix, - unsigned char *decode_matrix, - unsigned char *invert_matrix, - unsigned int *decode_index, - unsigned char *src_err_list, - unsigned char *src_in_err, - int nerrs, int nsrcerrs, int k, int m) -{ - int i, j, p; - int r; - unsigned char *backup, *b, s; - int incr = 0; - - b = malloc(MMAX * KMAX); - backup = malloc(MMAX * KMAX); - - if (b == NULL || backup == NULL) { - printf("Test failure! Error with malloc\n"); - free(b); - free(backup); - return -1; - } - // Construct matrix b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - for (j = 0; j < k; j++) { - b[k * i + j] = encode_matrix[k * r + j]; - backup[k * i + j] = encode_matrix[k * r + j]; - } - decode_index[i] = r; - } - incr = 0; - while (gf_invert_matrix(b, invert_matrix, k) < 0) { - if (nerrs == (m - k)) { - free(b); - free(backup); - printf("BAD MATRIX\n"); - return NO_INVERT_MATRIX; - } - incr++; - memcpy(b, backup, MMAX * KMAX); - for (i = nsrcerrs; i < nerrs - nsrcerrs; i++) { - if (src_err_list[i] == (decode_index[k - 1] + incr)) { - // skip the erased parity line - incr++; - continue; - } - } - if (decode_index[k - 1] + incr >= m) { - free(b); - free(backup); - printf("BAD MATRIX\n"); - return NO_INVERT_MATRIX; - } - decode_index[k - 1] += incr; - for (j = 0; j < k; j++) - b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j]; - - }; - - for (i = 0; i < nsrcerrs; i++) { - for (j = 0; j < k; j++) { - decode_matrix[k * i + j] = invert_matrix[k * src_err_list[i] + j]; - } - } - /* src_err_list from encode_matrix * invert of b for parity decoding */ - for (p = nsrcerrs; p < nerrs; p++) { - for (i = 0; i < k; i++) { - s = 0; - for (j = 0; j < k; j++) - s ^= gf_mul(invert_matrix[j * k + i], - encode_matrix[k * src_err_list[p] + j]); - - decode_matrix[k * p + i] = s; - } - } - free(b); - free(backup); - return 0; -} - -int main(int argc, char *argv[]) -{ - int re = 0; - int i, j, p, rtest, m, k; - int nerrs, nsrcerrs; - void *buf; - unsigned int decode_index[MMAX]; - unsigned char *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - unsigned char *encode_matrix, *decode_matrix, *invert_matrix, *g_tbls; - unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES]; - unsigned char *recov[TEST_SOURCES]; - - int rows, align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *temp_ubuffs[TEST_SOURCES]; - - printf("erasure_code_base_test: %dx%d ", TEST_SOURCES, TEST_LEN); - srand(TEST_SEED); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buffs[i] = buf; - } - - // Test erasure code by encode and recovery - - encode_matrix = malloc(MMAX * KMAX); - decode_matrix = malloc(MMAX * KMAX); - invert_matrix = malloc(MMAX * KMAX); - g_tbls = malloc(KMAX * TEST_SOURCES * 32); - if (encode_matrix == NULL || decode_matrix == NULL - || invert_matrix == NULL || g_tbls == NULL) { - printf("Test failure! Error with malloc\n"); - return -1; - } - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Generate encode matrix encode_matrix - // The matrix generated by gf_gen_rs_matrix - // is not always invertable. - gf_gen_rs_matrix(encode_matrix, m, k); - - // Generate g_tbls from encode matrix encode_matrix - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix encode_matrix - ec_encode_data_base(TEST_LEN, k, m - k, g_tbls, buffs, &buffs[k]); - - // Choose random buffers to be in erasure - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, src_in_err, - nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_base(TEST_LEN, k, nerrs, g_tbls, recov, &temp_buffs[k]); - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Generate g_tbls from encode matrix encode_matrix - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix encode_matrix - ec_encode_data_base(TEST_LEN, k, m - k, g_tbls, buffs, &buffs[k]); - - // Choose random buffers to be in erasure - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, src_in_err, - nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_base(TEST_LEN, k, nerrs, g_tbls, recov, &temp_buffs[k]); - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Do more random tests - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data_base(TEST_LEN, k, m - k, g_tbls, buffs, &buffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_base(TEST_LEN, k, nerrs, g_tbls, recov, &temp_buffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - return -1; - } - } - putchar('.'); - } - - // Run tests at end of buffer for Electric Fence - k = 16; - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - if (k > KMAX) - return -1; - - for (rows = 1; rows <= 16; rows++) { - m = k + rows; - if (m > MMAX) - return -1; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (size = EFENCE_TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < m; i++) { // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - } - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data_base(size, k, m - k, g_tbls, efence_buffs, - &efence_buffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = efence_buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_base(size, k, nerrs, g_tbls, recov, &temp_buffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != - memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]], - size)) { - printf("Efence: Fail error recovery (%d, %d, %d)\n", m, - k, nerrs); - - printf("size = %d\n", size); - - printf("Test erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], align); - printf("orig :"); - dump(efence_buffs[src_err_list[i]], align); - return -1; - } - } - } - - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~15; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < m; i++) { - memset(buffs[i], 0, TEST_LEN); // zero pad to check write-over - memset(temp_buffs[i], 0, TEST_LEN); // zero pad to check write-over - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - temp_ubuffs[i] = temp_buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - } - - for (i = 0; i < k; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data_base(size, k, m - k, g_tbls, ubuffs, &ubuffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = ubuffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_base(size, k, nerrs, g_tbls, recov, &temp_ubuffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_ubuffs[k + i], ubuffs[src_err_list[i]], size)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((unsigned char *)encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((unsigned char *)invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((unsigned char *)decode_matrix, m, k); - printf("orig data:\n"); - dump_matrix(ubuffs, m, 25); - printf("orig :"); - dump(ubuffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_ubuffs[k + i], 25); - return -1; - } - } - - // Confirm that padding around dests is unchanged - memset(temp_buffs[0], 0, PTR_ALIGN_CHK_B); // Make reference zero buff - - for (i = 0; i < m; i++) { - - offset = ubuffs[i] - buffs[i]; - - if (memcmp(buffs[i], temp_buffs[0], offset)) { - printf("Fail rand ualign encode pad start\n"); - return -1; - } - if (memcmp - (buffs[i] + offset + size, temp_buffs[0], - PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign encode pad end\n"); - return -1; - } - } - - for (i = 0; i < nerrs; i++) { - - offset = temp_ubuffs[k + i] - temp_buffs[k + i]; - if (memcmp(temp_buffs[k + i], temp_buffs[0], offset)) { - printf("Fail rand ualign decode pad start\n"); - return -1; - } - if (memcmp - (temp_buffs[k + i] + offset + size, temp_buffs[0], - PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign decode pad end\n"); - return -1; - } - } - - putchar('.'); - } - - // Test size alignment - - align = (LEN_ALIGN_CHK_B != 0) ? 13 : 16; - - for (size = TEST_LEN; size > 0; size -= align) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - for (i = 0; i < k; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data_base(size, k, m - k, g_tbls, buffs, &buffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_base(size, k, nerrs, g_tbls, recov, &temp_buffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], size)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((unsigned char *)encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((unsigned char *)invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((unsigned char *)decode_matrix, m, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - return -1; - } - } - } - - printf("done EC tests: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/erasure-code-perf.c b/pkg/storage/erasure/isal/src/erasure-code-perf.c deleted file mode 100644 index b01418209..000000000 --- a/pkg/storage/erasure/isal/src/erasure-code-perf.c +++ /dev/null @@ -1,168 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 32 -# define TEST_LEN(m) ((128*1024 / m) & ~(64-1)) -# define TEST_LOOPS(m) (10000*m) -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 32 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64-1)) -# define TEST_LOOPS(m) (50*m) -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS(m) 1000 -# endif -# endif -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i, j, rtest, m, k, nerrs, r; - void *buf; - u8 *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; - u8 g_tbls[KMAX * TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; - u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - struct perf start, stop; - - // Pick test parameters - m = 14; - k = 10; - nerrs = 4; - const u8 err_list[] = {2, 4, 5, 7}; - - printf("erasure_code_perf: %dx%d %d\n", m, TEST_LEN(m), nerrs); - - if (m > MMAX || k > KMAX || nerrs > (m - k)){ - printf(" Input test parameter error\n"); - return -1; - } - - memcpy(src_err_list, err_list, nerrs); - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0; i < nerrs; i++) - src_in_err[src_err_list[i]] = 1; - - // Allocate the arrays - for (i = 0; i < m; i++) { - if (posix_memalign(&buf, 64, TEST_LEN(m))) { - printf("alloc error: Fail\n"); - return -1; - } - buffs[i] = buf; - } - - for (i = 0; i < (m - k); i++) { - if (posix_memalign(&buf, 64, TEST_LEN(m))) { - printf("alloc error: Fail\n"); - return -1; - } - temp_buffs[i] = buf; - } - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN(m); j++) - buffs[i][j] = rand(); - - gf_gen_rs_matrix(a, m, k); - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - - // Start encode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Make parity vects - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - } - perf_stop(&stop); - printf("erasure_code_encode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (m) * rtest); - - // Start decode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - recov[i] = buffs[r]; - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix(b, d, k) < 0) { - printf("BAD MATRIX\n"); - return -1; - } - - for (i = 0; i < nerrs; i++) - for (j = 0; j < k; j++) - c[k * i + j] = d[k * src_err_list[i] + j]; - - // Recover data - ec_init_tables(k, nerrs, c, g_tbls); - ec_encode_data(TEST_LEN(m), k, nerrs, g_tbls, recov, temp_buffs); - } - perf_stop(&stop); - - for (i = 0; i < nerrs; i++) { - if (0 != memcmp(temp_buffs[i], buffs[src_err_list[i]], TEST_LEN(m))) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - return -1; - } - } - - printf("erasure_code_decode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (k + nerrs) * rtest); - - printf("done all: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/erasure-code-sse-perf.c b/pkg/storage/erasure/isal/src/erasure-code-sse-perf.c deleted file mode 100644 index e873a36f6..000000000 --- a/pkg/storage/erasure/isal/src/erasure-code-sse-perf.c +++ /dev/null @@ -1,168 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 32 -# define TEST_LEN(m) ((128*1024 / m) & ~(64-1)) -# define TEST_LOOPS(m) (10000*m) -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 32 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64-1)) -# define TEST_LOOPS(m) (50*m) -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS(m) 1000 -# endif -# endif -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i, j, rtest, m, k, nerrs, r; - void *buf; - u8 *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; - u8 g_tbls[KMAX * TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; - u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - struct perf start, stop; - - // Pick test parameters - m = 14; - k = 10; - nerrs = 4; - const u8 err_list[] = {2, 4, 5, 7}; - - printf("erasure_code_sse_perf: %dx%d %d\n", m, TEST_LEN(m), nerrs); - - if (m > MMAX || k > KMAX || nerrs > (m - k)){ - printf(" Input test parameter error\n"); - return -1; - } - - memcpy(src_err_list, err_list, nerrs); - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0; i < nerrs; i++) - src_in_err[src_err_list[i]] = 1; - - // Allocate the arrays - for (i = 0; i < m; i++) { - if (posix_memalign(&buf, 64, TEST_LEN(m))) { - printf("alloc error: Fail\n"); - return -1; - } - buffs[i] = buf; - } - - for (i = 0; i < (m - k); i++) { - if (posix_memalign(&buf, 64, TEST_LEN(m))) { - printf("alloc error: Fail\n"); - return -1; - } - temp_buffs[i] = buf; - } - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN(m); j++) - buffs[i][j] = rand(); - - gf_gen_rs_matrix(a, m, k); - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data_sse(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - - // Start encode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Make parity vects - ec_init_tables(k, m - k, &a[k * k], g_tbls); - ec_encode_data_sse(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); - } - perf_stop(&stop); - printf("erasure_code_sse_encode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (m) * rtest); - - // Start decode test - perf_start(&start); - for (rtest = 0; rtest < TEST_LOOPS(m); rtest++) { - // Construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - recov[i] = buffs[r]; - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix(b, d, k) < 0) { - printf("BAD MATRIX\n"); - return -1; - } - - for (i = 0; i < nerrs; i++) - for (j = 0; j < k; j++) - c[k * i + j] = d[k * src_err_list[i] + j]; - - // Recover data - ec_init_tables(k, nerrs, c, g_tbls); - ec_encode_data_sse(TEST_LEN(m), k, nerrs, g_tbls, recov, temp_buffs); - } - perf_stop(&stop); - - for (i = 0; i < nerrs; i++) { - if (0 != memcmp(temp_buffs[i], buffs[src_err_list[i]], TEST_LEN(m))) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - return -1; - } - } - - printf("erasure_code_sse_decode" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)(TEST_LEN(m)) * (k + nerrs) * rtest); - - printf("done all: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/erasure-code-sse-test.c b/pkg/storage/erasure/isal/src/erasure-code-sse-test.c deleted file mode 100644 index fb83f0aea..000000000 --- a/pkg/storage/erasure/isal/src/erasure-code-sse-test.c +++ /dev/null @@ -1,764 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) - -#ifndef TEST_SOURCES -# define TEST_SOURCES 127 -#endif -#ifndef RANDOMS -# define RANDOMS 200 -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -#define EFENCE_TEST_MIN_SIZE 16 - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -#ifndef TEST_SEED -#define TEST_SEED 11 -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -// Generate Random errors -static void gen_err_list(unsigned char *src_err_list, - unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs, int k, int m) -{ - int i, err; - int nerrs = 0, nsrcerrs = 0; - - for (i = 0, nerrs = 0, nsrcerrs = 0; i < m && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) { - src_err_list[nerrs++] = i; - if (i < k) { - nsrcerrs++; - } - } - } - if (nerrs == 0) { // should have at least one error - while ((err = (rand() % KMAX)) >= m) ; - src_err_list[nerrs++] = err; - src_in_err[err] = 1; - if (err < k) - nsrcerrs = 1; - } - *pnerrs = nerrs; - *pnsrcerrs = nsrcerrs; - return; -} - -#define NO_INVERT_MATRIX -2 -// Generate decode matrix from encode matrix -static int gf_gen_decode_matrix(unsigned char *encode_matrix, - unsigned char *decode_matrix, - unsigned char *invert_matrix, - unsigned int *decode_index, - unsigned char *src_err_list, - unsigned char *src_in_err, - int nerrs, int nsrcerrs, int k, int m) -{ - int i, j, p; - int r; - unsigned char *backup, *b, s; - int incr = 0; - - b = malloc(MMAX * KMAX); - backup = malloc(MMAX * KMAX); - - if (b == NULL || backup == NULL) { - printf("Test failure! Error with malloc\n"); - free(b); - free(backup); - return -1; - } - // Construct matrix b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - for (j = 0; j < k; j++) { - b[k * i + j] = encode_matrix[k * r + j]; - backup[k * i + j] = encode_matrix[k * r + j]; - } - decode_index[i] = r; - } - incr = 0; - while (gf_invert_matrix(b, invert_matrix, k) < 0) { - if (nerrs == (m - k)) { - free(b); - free(backup); - printf("BAD MATRIX\n"); - return NO_INVERT_MATRIX; - } - incr++; - memcpy(b, backup, MMAX * KMAX); - for (i = nsrcerrs; i < nerrs - nsrcerrs; i++) { - if (src_err_list[i] == (decode_index[k - 1] + incr)) { - // skip the erased parity line - incr++; - continue; - } - } - if (decode_index[k - 1] + incr >= m) { - free(b); - free(backup); - printf("BAD MATRIX\n"); - return NO_INVERT_MATRIX; - } - decode_index[k - 1] += incr; - for (j = 0; j < k; j++) - b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j]; - - }; - - for (i = 0; i < nsrcerrs; i++) { - for (j = 0; j < k; j++) { - decode_matrix[k * i + j] = invert_matrix[k * src_err_list[i] + j]; - } - } - /* src_err_list from encode_matrix * invert of b for parity decoding */ - for (p = nsrcerrs; p < nerrs; p++) { - for (i = 0; i < k; i++) { - s = 0; - for (j = 0; j < k; j++) - s ^= gf_mul(invert_matrix[j * k + i], - encode_matrix[k * src_err_list[p] + j]); - - decode_matrix[k * p + i] = s; - } - } - free(b); - free(backup); - return 0; -} - -int main(int argc, char *argv[]) -{ - int re = 0; - int i, j, p, rtest, m, k; - int nerrs, nsrcerrs; - void *buf; - unsigned int decode_index[MMAX]; - unsigned char *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - unsigned char *encode_matrix, *decode_matrix, *invert_matrix, *g_tbls; - unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES]; - unsigned char *recov[TEST_SOURCES]; - - int rows, align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *temp_ubuffs[TEST_SOURCES]; - - printf("erasure_code_sse_test: %dx%d ", TEST_SOURCES, TEST_LEN); - srand(TEST_SEED); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buffs[i] = buf; - } - - // Test erasure code by encode and recovery - - encode_matrix = malloc(MMAX * KMAX); - decode_matrix = malloc(MMAX * KMAX); - invert_matrix = malloc(MMAX * KMAX); - g_tbls = malloc(KMAX * TEST_SOURCES * 32); - if (encode_matrix == NULL || decode_matrix == NULL - || invert_matrix == NULL || g_tbls == NULL) { - printf("Test failure! Error with malloc\n"); - return -1; - } - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Generate encode matrix encode_matrix - // The matrix generated by gf_gen_rs_matrix - // is not always invertable. - gf_gen_rs_matrix(encode_matrix, m, k); - - // Generate g_tbls from encode matrix encode_matrix - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix encode_matrix - ec_encode_data_sse(TEST_LEN, k, m - k, g_tbls, buffs, &buffs[k]); - - // Choose random buffers to be in erasure - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, src_in_err, - nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_sse(TEST_LEN, k, nerrs, g_tbls, recov, &temp_buffs[k]); - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Generate g_tbls from encode matrix encode_matrix - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix encode_matrix - ec_encode_data_sse(TEST_LEN, k, m - k, g_tbls, buffs, &buffs[k]); - - // Choose random buffers to be in erasure - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, src_in_err, - nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_sse(TEST_LEN, k, nerrs, g_tbls, recov, &temp_buffs[k]); - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Do more random tests - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data_sse(TEST_LEN, k, m - k, g_tbls, buffs, &buffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_sse(TEST_LEN, k, nerrs, g_tbls, recov, &temp_buffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - return -1; - } - } - putchar('.'); - } - - // Run tests at end of buffer for Electric Fence - k = 16; - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - if (k > KMAX) - return -1; - - for (rows = 1; rows <= 16; rows++) { - m = k + rows; - if (m > MMAX) - return -1; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (size = EFENCE_TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < m; i++) { // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - } - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data_sse(size, k, m - k, g_tbls, efence_buffs, - &efence_buffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = efence_buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_sse(size, k, nerrs, g_tbls, recov, &temp_buffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != - memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]], - size)) { - printf("Efence: Fail error recovery (%d, %d, %d)\n", m, - k, nerrs); - - printf("size = %d\n", size); - - printf("Test erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], align); - printf("orig :"); - dump(efence_buffs[src_err_list[i]], align); - return -1; - } - } - } - - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~15; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < m; i++) { - memset(buffs[i], 0, TEST_LEN); // zero pad to check write-over - memset(temp_buffs[i], 0, TEST_LEN); // zero pad to check write-over - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - temp_ubuffs[i] = temp_buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - } - - for (i = 0; i < k; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data_sse(size, k, m - k, g_tbls, ubuffs, &ubuffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = ubuffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_sse(size, k, nerrs, g_tbls, recov, &temp_ubuffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_ubuffs[k + i], ubuffs[src_err_list[i]], size)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((unsigned char *)encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((unsigned char *)invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((unsigned char *)decode_matrix, m, k); - printf("orig data:\n"); - dump_matrix(ubuffs, m, 25); - printf("orig :"); - dump(ubuffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_ubuffs[k + i], 25); - return -1; - } - } - - // Confirm that padding around dests is unchanged - memset(temp_buffs[0], 0, PTR_ALIGN_CHK_B); // Make reference zero buff - - for (i = 0; i < m; i++) { - - offset = ubuffs[i] - buffs[i]; - - if (memcmp(buffs[i], temp_buffs[0], offset)) { - printf("Fail rand ualign encode pad start\n"); - return -1; - } - if (memcmp - (buffs[i] + offset + size, temp_buffs[0], - PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign encode pad end\n"); - return -1; - } - } - - for (i = 0; i < nerrs; i++) { - - offset = temp_ubuffs[k + i] - temp_buffs[k + i]; - if (memcmp(temp_buffs[k + i], temp_buffs[0], offset)) { - printf("Fail rand ualign decode pad start\n"); - return -1; - } - if (memcmp - (temp_buffs[k + i] + offset + size, temp_buffs[0], - PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign decode pad end\n"); - return -1; - } - } - - putchar('.'); - } - - // Test size alignment - - align = (LEN_ALIGN_CHK_B != 0) ? 13 : 16; - - for (size = TEST_LEN; size > 0; size -= align) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - for (i = 0; i < k; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data_sse(size, k, m - k, g_tbls, buffs, &buffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data_sse(size, k, nerrs, g_tbls, recov, &temp_buffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], size)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((unsigned char *)encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((unsigned char *)invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((unsigned char *)decode_matrix, m, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - return -1; - } - } - } - - printf("done EC tests: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/erasure-code-test.c b/pkg/storage/erasure/isal/src/erasure-code-test.c deleted file mode 100644 index 2e7ccd3c1..000000000 --- a/pkg/storage/erasure/isal/src/erasure-code-test.c +++ /dev/null @@ -1,763 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) - -#ifndef TEST_SOURCES -# define TEST_SOURCES 127 -#endif -#ifndef RANDOMS -# define RANDOMS 200 -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -#define EFENCE_TEST_MIN_SIZE 16 - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -#ifndef TEST_SEED -#define TEST_SEED 11 -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -// Generate Random errors -static void gen_err_list(unsigned char *src_err_list, - unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs, int k, int m) -{ - int i, err; - int nerrs = 0, nsrcerrs = 0; - - for (i = 0, nerrs = 0, nsrcerrs = 0; i < m && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) { - src_err_list[nerrs++] = i; - if (i < k) { - nsrcerrs++; - } - } - } - if (nerrs == 0) { // should have at least one error - while ((err = (rand() % KMAX)) >= m) ; - src_err_list[nerrs++] = err; - src_in_err[err] = 1; - if (err < k) - nsrcerrs = 1; - } - *pnerrs = nerrs; - *pnsrcerrs = nsrcerrs; - return; -} - -#define NO_INVERT_MATRIX -2 -// Generate decode matrix from encode matrix -static int gf_gen_decode_matrix(unsigned char *encode_matrix, - unsigned char *decode_matrix, - unsigned char *invert_matrix, - unsigned int *decode_index, - unsigned char *src_err_list, - unsigned char *src_in_err, - int nerrs, int nsrcerrs, int k, int m) -{ - int i, j, p; - int r; - unsigned char *backup, *b, s; - int incr = 0; - - b = malloc(MMAX * KMAX); - backup = malloc(MMAX * KMAX); - - if (b == NULL || backup == NULL) { - printf("Test failure! Error with malloc\n"); - free(b); - free(backup); - return -1; - } - // Construct matrix b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) - r++; - for (j = 0; j < k; j++) { - b[k * i + j] = encode_matrix[k * r + j]; - backup[k * i + j] = encode_matrix[k * r + j]; - } - decode_index[i] = r; - } - incr = 0; - while (gf_invert_matrix(b, invert_matrix, k) < 0) { - if (nerrs == (m - k)) { - free(b); - free(backup); - printf("BAD MATRIX\n"); - return NO_INVERT_MATRIX; - } - incr++; - memcpy(b, backup, MMAX * KMAX); - for (i = nsrcerrs; i < nerrs - nsrcerrs; i++) { - if (src_err_list[i] == (decode_index[k - 1] + incr)) { - // skip the erased parity line - incr++; - continue; - } - } - if (decode_index[k - 1] + incr >= m) { - free(b); - free(backup); - printf("BAD MATRIX\n"); - return NO_INVERT_MATRIX; - } - decode_index[k - 1] += incr; - for (j = 0; j < k; j++) - b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j]; - - }; - - for (i = 0; i < nsrcerrs; i++) { - for (j = 0; j < k; j++) { - decode_matrix[k * i + j] = invert_matrix[k * src_err_list[i] + j]; - } - } - /* src_err_list from encode_matrix * invert of b for parity decoding */ - for (p = nsrcerrs; p < nerrs; p++) { - for (i = 0; i < k; i++) { - s = 0; - for (j = 0; j < k; j++) - s ^= gf_mul(invert_matrix[j * k + i], - encode_matrix[k * src_err_list[p] + j]); - - decode_matrix[k * p + i] = s; - } - } - free(b); - free(backup); - return 0; -} - -int main(int argc, char *argv[]) -{ - int re = 0; - int i, j, p, rtest, m, k; - int nerrs, nsrcerrs; - void *buf; - unsigned int decode_index[MMAX]; - unsigned char *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - unsigned char *encode_matrix, *decode_matrix, *invert_matrix, *g_tbls; - unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES]; - unsigned char *recov[TEST_SOURCES]; - - int rows, align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *temp_ubuffs[TEST_SOURCES]; - - printf("erasure_code_test: %dx%d ", TEST_SOURCES, TEST_LEN); - srand(TEST_SEED); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buffs[i] = buf; - } - - // Test erasure code by encode and recovery - - encode_matrix = malloc(MMAX * KMAX); - decode_matrix = malloc(MMAX * KMAX); - invert_matrix = malloc(MMAX * KMAX); - g_tbls = malloc(KMAX * TEST_SOURCES * 32); - if (encode_matrix == NULL || decode_matrix == NULL - || invert_matrix == NULL || g_tbls == NULL) { - printf("Test failure! Error with malloc\n"); - return -1; - } - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Generate encode matrix encode_matrix - // The matrix generated by gf_gen_rs_matrix - // is not always invertable. - gf_gen_rs_matrix(encode_matrix, m, k); - - // Generate g_tbls from encode matrix encode_matrix - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix encode_matrix - ec_encode_data(TEST_LEN, k, m - k, g_tbls, buffs, &buffs[k]); - - // Choose random buffers to be in erasure - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, src_in_err, - nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data(TEST_LEN, k, nerrs, g_tbls, recov, &temp_buffs[k]); - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Generate g_tbls from encode matrix encode_matrix - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix encode_matrix - ec_encode_data(TEST_LEN, k, m - k, g_tbls, buffs, &buffs[k]); - - // Choose random buffers to be in erasure - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, src_in_err, - nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data(TEST_LEN, k, nerrs, g_tbls, recov, &temp_buffs[k]); - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Do more random tests - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data(TEST_LEN, k, m - k, g_tbls, buffs, &buffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data(TEST_LEN, k, nerrs, g_tbls, recov, &temp_buffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - return -1; - } - } - putchar('.'); - } - - // Run tests at end of buffer for Electric Fence - k = 16; - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - if (k > KMAX) - return -1; - - for (rows = 1; rows <= 16; rows++) { - m = k + rows; - if (m > MMAX) - return -1; - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (size = EFENCE_TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < m; i++) { // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - } - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data(size, k, m - k, g_tbls, efence_buffs, &efence_buffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = efence_buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data(size, k, nerrs, g_tbls, recov, &temp_buffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != - memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]], - size)) { - printf("Efence: Fail error recovery (%d, %d, %d)\n", m, - k, nerrs); - - printf("size = %d\n", size); - - printf("Test erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((u8 *) encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((u8 *) decode_matrix, m, k); - - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], align); - printf("orig :"); - dump(efence_buffs[src_err_list[i]], align); - return -1; - } - } - } - - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~15; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < m; i++) { - memset(buffs[i], 0, TEST_LEN); // zero pad to check write-over - memset(temp_buffs[i], 0, TEST_LEN); // zero pad to check write-over - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - temp_ubuffs[i] = temp_buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - } - - for (i = 0; i < k; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data(size, k, m - k, g_tbls, ubuffs, &ubuffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = ubuffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data(size, k, nerrs, g_tbls, recov, &temp_ubuffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_ubuffs[k + i], ubuffs[src_err_list[i]], size)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((unsigned char *)encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((unsigned char *)invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((unsigned char *)decode_matrix, m, k); - printf("orig data:\n"); - dump_matrix(ubuffs, m, 25); - printf("orig :"); - dump(ubuffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_ubuffs[k + i], 25); - return -1; - } - } - - // Confirm that padding around dests is unchanged - memset(temp_buffs[0], 0, PTR_ALIGN_CHK_B); // Make reference zero buff - - for (i = 0; i < m; i++) { - - offset = ubuffs[i] - buffs[i]; - - if (memcmp(buffs[i], temp_buffs[0], offset)) { - printf("Fail rand ualign encode pad start\n"); - return -1; - } - if (memcmp - (buffs[i] + offset + size, temp_buffs[0], - PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign encode pad end\n"); - return -1; - } - } - - for (i = 0; i < nerrs; i++) { - - offset = temp_ubuffs[k + i] - temp_buffs[k + i]; - if (memcmp(temp_buffs[k + i], temp_buffs[0], offset)) { - printf("Fail rand ualign decode pad start\n"); - return -1; - } - if (memcmp - (temp_buffs[k + i] + offset + size, temp_buffs[0], - PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign decode pad end\n"); - return -1; - } - } - - putchar('.'); - } - - // Test size alignment - - align = (LEN_ALIGN_CHK_B != 0) ? 13 : 16; - - for (size = TEST_LEN; size > 0; size -= align) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - for (i = 0; i < k; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - // The matrix generated by gf_gen_cauchy1_matrix - // is always invertable. - gf_gen_cauchy1_matrix(encode_matrix, m, k); - - // Make parity vects - // Generate g_tbls from encode matrix a - ec_init_tables(k, m - k, &encode_matrix[k * k], g_tbls); - // Perform matrix dot_prod for EC encoding - // using g_tbls from encode matrix a - ec_encode_data(size, k, m - k, g_tbls, buffs, &buffs[k]); - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); - // Generate decode matrix - re = gf_gen_decode_matrix(encode_matrix, decode_matrix, - invert_matrix, decode_index, src_err_list, - src_in_err, nerrs, nsrcerrs, k, m); - if (re != 0) { - printf("Fail to gf_gen_decode_matrix\n"); - return -1; - } - // Pack recovery array as list of valid sources - // Its order must be the same as the order - // to generate matrix b in gf_gen_decode_matrix - for (i = 0; i < k; i++) { - recov[i] = buffs[decode_index[i]]; - } - - // Recover data - ec_init_tables(k, nerrs, decode_matrix, g_tbls); - ec_encode_data(size, k, nerrs, g_tbls, recov, &temp_buffs[k]); - - for (i = 0; i < nerrs; i++) { - - if (0 != memcmp(temp_buffs[k + i], buffs[src_err_list[i]], size)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (j = 0; j < nerrs; j++) - printf(" %d", src_err_list[j]); - printf(" - Index = "); - for (p = 0; p < k; p++) - printf(" %d", decode_index[p]); - printf("\nencode_matrix:\n"); - dump_u8xu8((unsigned char *)encode_matrix, m, k); - printf("inv b:\n"); - dump_u8xu8((unsigned char *)invert_matrix, k, k); - printf("\ndecode_matrix:\n"); - dump_u8xu8((unsigned char *)decode_matrix, m, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buffs[k + i], 25); - return -1; - } - } - } - - printf("done EC tests: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse-perf.c b/pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse-perf.c deleted file mode 100644 index e3af1d977..000000000 --- a/pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse-perf.c +++ /dev/null @@ -1,216 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_2vect_dot_prod_sse -#endif - -#define str(s) #s -#define xstr(s) str(s) - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 10 -# define TEST_LEN 8*1024 -# define TEST_LOOPS 40000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1)) -# define TEST_LOOPS 100 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g_tbls[2 * TEST_SOURCES * 32]; - u8 *dest1, *dest2, *dest_ref1, *dest_ref2, *dest_ptrs[2]; - u8 *buffs[TEST_SOURCES]; - struct perf start, stop; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d\n", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref2 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - - // Performance test - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - } - - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - -#ifdef DO_REF_PERF - perf_start(&start); - for (i = 0; i < TEST_LOOPS / 100; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - } - perf_stop(&stop); - printf("gf_2vect_dot_prod_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 2) * i); -#endif - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - } - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - } - perf_stop(&stop); - printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 2) * i); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - - printf("pass perf check\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse-test.c b/pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse-test.c deleted file mode 100644 index d7a2729bd..000000000 --- a/pkg/storage/erasure/isal/src/gf-2vect-dot-prod-sse-test.c +++ /dev/null @@ -1,477 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_2vect_dot_prod_sse -#endif -#ifndef TEST_MIN_SIZE -# define TEST_MIN_SIZE 16 -#endif - -#define str(s) #s -#define xstr(s) str(s) - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) -#define TEST_MEM TEST_SIZE -#define TEST_LOOPS 10000 -#define TEST_TYPE_STR "" - -#ifndef TEST_SOURCES -# define TEST_SOURCES 16 -#endif -#ifndef RANDOMS -# define RANDOMS 20 -#endif - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j, rtest, srcs; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g_tbls[2 * TEST_SOURCES * 32]; - u8 *dest1, *dest2, *dest_ref1, *dest_ref2, *dest_ptrs[2]; - u8 *buffs[TEST_SOURCES]; - - int align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *udest_ptrs[2]; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d ", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref2 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - - // Test of all zeros - for (i = 0; i < TEST_SOURCES; i++) - memset(buffs[i], 0, TEST_LEN); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - memset(g1, 2, TEST_SOURCES); - memset(g2, 1, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[32 * TEST_SOURCES + i * 32]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - - putchar('.'); - - // Rand data test - - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - - putchar('.'); - } - - // Rand data test with varied parameters - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (srcs = TEST_SOURCES; srcs > 0; srcs--) { - for (i = 0; i < srcs; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[32 * srcs], buffs, - dest_ref2); - - FUNCTION_UNDER_TEST(TEST_LEN, srcs, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test1 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test2 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - - putchar('.'); - } - } - - // Run tests at end of buffer for Electric Fence - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - for (size = TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[0], efence_buffs, dest_ref1); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - efence_buffs, dest_ref2); - - FUNCTION_UNDER_TEST(size, TEST_SOURCES, g_tbls, efence_buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, align); - printf("dprod_dut:"); - dump(dest1, align); - return -1; - } - - if (0 != memcmp(dest_ref2, dest2, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, align); - printf("dprod_dut:"); - dump(dest2, align); - return -1; - } - - putchar('.'); - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~(TEST_MIN_SIZE - 1); - srcs = rand() % TEST_SOURCES; - if (srcs == 0) - continue; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < srcs; i++) - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - - udest_ptrs[0] = dest1 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[1] = dest2 + (rand() & (PTR_ALIGN_CHK_B - offset)); - - memset(dest1, 0, TEST_LEN); // zero pad to check write-over - memset(dest2, 0, TEST_LEN); - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], ubuffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], ubuffs, dest_ref2); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptrs); - - if (memcmp(dest_ref1, udest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(udest_ptrs[0], 25); - return -1; - } - if (memcmp(dest_ref2, udest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(udest_ptrs[1], 25); - return -1; - } - // Confirm that padding around dests is unchanged - memset(dest_ref1, 0, PTR_ALIGN_CHK_B); // Make reference zero buff - offset = udest_ptrs[0] - dest1; - - if (memcmp(dest1, dest_ref1, offset)) { - printf("Fail rand ualign pad1 start\n"); - return -1; - } - if (memcmp(dest1 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad1 end\n"); - return -1; - } - - offset = udest_ptrs[1] - dest2; - if (memcmp(dest2, dest_ref1, offset)) { - printf("Fail rand ualign pad2 start\n"); - return -1; - } - if (memcmp(dest2 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad2 end\n"); - return -1; - } - - putchar('.'); - } - - // Test all size alignment - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - - for (size = TEST_LEN; size >= TEST_MIN_SIZE; size -= align) { - srcs = TEST_SOURCES; - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], buffs, dest_ref2); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest_ptrs); - - if (memcmp(dest_ref1, dest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest_ptrs[0], 25); - return -1; - } - if (memcmp(dest_ref2, dest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest_ptrs[1], 25); - return -1; - } - } - - printf("Pass\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse-perf.c b/pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse-perf.c deleted file mode 100644 index cdae2460d..000000000 --- a/pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse-perf.c +++ /dev/null @@ -1,246 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_3vect_dot_prod_sse -#endif - -#define str(s) #s -#define xstr(s) str(s) - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 10 -# define TEST_LEN 8*1024 -# define TEST_LOOPS 40000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1)) -# define TEST_LOOPS 100 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g3[TEST_SOURCES]; - u8 g_tbls[3 * TEST_SOURCES * 32], *dest_ptrs[3], *buffs[TEST_SOURCES]; - u8 *dest1, *dest2, *dest3, *dest_ref1, *dest_ref2, *dest_ref3; - struct perf start, stop; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d\n", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref3 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - dest_ptrs[2] = dest3; - - // Performance test - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - } - - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], buffs, - dest_ref3); - -#ifdef DO_REF_PERF - perf_start(&start); - for (i = 0; i < TEST_LOOPS / 100; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - buffs, dest_ref3); - } - perf_stop(&stop); - printf("gf_3vect_dot_prod_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 3) * i); -#endif - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - } - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - } - perf_stop(&stop); - printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 3) * i); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test3\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - - printf("pass perf check\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse-test.c b/pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse-test.c deleted file mode 100644 index 9300fe1cc..000000000 --- a/pkg/storage/erasure/isal/src/gf-3vect-dot-prod-sse-test.c +++ /dev/null @@ -1,583 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_3vect_dot_prod_sse -#endif -#ifndef TEST_MIN_SIZE -# define TEST_MIN_SIZE 16 -#endif - -#define str(s) #s -#define xstr(s) str(s) - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) -#define TEST_MEM TEST_SIZE -#define TEST_LOOPS 10000 -#define TEST_TYPE_STR "" - -#ifndef TEST_SOURCES -# define TEST_SOURCES 16 -#endif -#ifndef RANDOMS -# define RANDOMS 20 -#endif - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j, rtest, srcs; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g3[TEST_SOURCES]; - u8 g_tbls[3 * TEST_SOURCES * 32], *dest_ptrs[3], *buffs[TEST_SOURCES]; - u8 *dest1, *dest2, *dest3, *dest_ref1, *dest_ref2, *dest_ref3; - - int align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *udest_ptrs[3]; - printf(xstr(FUNCTION_UNDER_TEST) "_test: %dx%d ", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail");; - return -1; - } - dest_ref2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref3 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - dest_ptrs[2] = dest3; - - // Test of all zeros - for (i = 0; i < TEST_SOURCES; i++) - memset(buffs[i], 0, TEST_LEN); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - memset(dest_ref3, 0, TEST_LEN); - memset(g1, 2, TEST_SOURCES); - memset(g2, 1, TEST_SOURCES); - memset(g3, 7, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[32 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g3[i], &g_tbls[64 * TEST_SOURCES + i * 32]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], buffs, - dest_ref3); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail zero" xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test3\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - - putchar('.'); - - // Rand data test - - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - buffs, dest_ref3); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test3 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - - putchar('.'); - } - - // Rand data test with varied parameters - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (srcs = TEST_SOURCES; srcs > 0; srcs--) { - for (i = 0; i < srcs; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[32 * srcs], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[64 * srcs], buffs, - dest_ref3); - - FUNCTION_UNDER_TEST(TEST_LEN, srcs, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test1 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test2 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test3 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - - putchar('.'); - } - } - - // Run tests at end of buffer for Electric Fence - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - for (size = TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[0], efence_buffs, dest_ref1); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - efence_buffs, dest_ref2); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - efence_buffs, dest_ref3); - - FUNCTION_UNDER_TEST(size, TEST_SOURCES, g_tbls, efence_buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, align); - printf("dprod_dut:"); - dump(dest1, align); - return -1; - } - - if (0 != memcmp(dest_ref2, dest2, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, align); - printf("dprod_dut:"); - dump(dest2, align); - return -1; - } - - if (0 != memcmp(dest_ref3, dest3, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test3 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, align); - printf("dprod_dut:"); - dump(dest3, align); - return -1; - } - - putchar('.'); - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~(TEST_MIN_SIZE - 1); - srcs = rand() % TEST_SOURCES; - if (srcs == 0) - continue; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < srcs; i++) - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - - udest_ptrs[0] = dest1 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[1] = dest2 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[2] = dest3 + (rand() & (PTR_ALIGN_CHK_B - offset)); - - memset(dest1, 0, TEST_LEN); // zero pad to check write-over - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], ubuffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], ubuffs, dest_ref2); - gf_vect_dot_prod_base(size, srcs, &g_tbls[64 * srcs], ubuffs, dest_ref3); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptrs); - - if (memcmp(dest_ref1, udest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(udest_ptrs[0], 25); - return -1; - } - if (memcmp(dest_ref2, udest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(udest_ptrs[1], 25); - return -1; - } - if (memcmp(dest_ref3, udest_ptrs[2], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(udest_ptrs[2], 25); - return -1; - } - // Confirm that padding around dests is unchanged - memset(dest_ref1, 0, PTR_ALIGN_CHK_B); // Make reference zero buff - offset = udest_ptrs[0] - dest1; - - if (memcmp(dest1, dest_ref1, offset)) { - printf("Fail rand ualign pad1 start\n"); - return -1; - } - if (memcmp(dest1 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad1 end\n"); - return -1; - } - - offset = udest_ptrs[1] - dest2; - if (memcmp(dest2, dest_ref1, offset)) { - printf("Fail rand ualign pad2 start\n"); - return -1; - } - if (memcmp(dest2 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad2 end\n"); - return -1; - } - - offset = udest_ptrs[2] - dest3; - if (memcmp(dest3, dest_ref1, offset)) { - printf("Fail rand ualign pad3 start\n"); - return -1; - } - if (memcmp(dest3 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad3 end\n");; - return -1; - } - - putchar('.'); - } - - // Test all size alignment - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - - for (size = TEST_LEN; size >= TEST_MIN_SIZE; size -= align) { - srcs = TEST_SOURCES; - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], buffs, dest_ref2); - gf_vect_dot_prod_base(size, srcs, &g_tbls[64 * srcs], buffs, dest_ref3); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest_ptrs); - - if (memcmp(dest_ref1, dest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest_ptrs[0], 25); - return -1; - } - if (memcmp(dest_ref2, dest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest_ptrs[1], 25); - return -1; - } - if (memcmp(dest_ref3, dest_ptrs[2], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest_ptrs[2], 25); - return -1; - } - } - - printf("Pass\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse-perf.c b/pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse-perf.c deleted file mode 100644 index 2948daac6..000000000 --- a/pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse-perf.c +++ /dev/null @@ -1,281 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_4vect_dot_prod_sse -#endif - -#define str(s) #s -#define xstr(s) str(s) - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 10 -# define TEST_LEN 8*1024 -# define TEST_LOOPS 40000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1)) -# define TEST_LOOPS 100 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g3[TEST_SOURCES]; - u8 g4[TEST_SOURCES], g_tbls[4 * TEST_SOURCES * 32], *buffs[TEST_SOURCES]; - u8 *dest1, *dest2, *dest3, *dest4, *dest_ref1, *dest_ref2, *dest_ref3; - u8 *dest_ref4, *dest_ptrs[4]; - struct perf start, stop; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d\n", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref4 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - dest_ptrs[2] = dest3; - dest_ptrs[3] = dest4; - - // Performance test - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest4, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - memset(dest_ref3, 0, TEST_LEN); - memset(dest_ref4, 0, TEST_LEN); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - } - - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g4[j], &g_tbls[(96 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], buffs, - dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], buffs, - dest_ref4); - -#ifdef DO_REF_PERF - perf_start(&start); - for (i = 0; i < TEST_LOOPS / 100; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g4[j], &g_tbls[(96 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - buffs, dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], - buffs, dest_ref4); - } - perf_stop(&stop); - printf("gf_4vect_dot_prod_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 4) * i); -#endif - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g4[j], &g_tbls[(96 * TEST_SOURCES) + (j * 32)]); - } - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - } - perf_stop(&stop); - printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 4) * i); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test3\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test3\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - - printf("pass perf check\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse-test.c b/pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse-test.c deleted file mode 100644 index 5371a8c04..000000000 --- a/pkg/storage/erasure/isal/src/gf-4vect-dot-prod-sse-test.c +++ /dev/null @@ -1,692 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_4vect_dot_prod_sse -#endif -#ifndef TEST_MIN_SIZE -# define TEST_MIN_SIZE 16 -#endif - -#define str(s) #s -#define xstr(s) str(s) - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) -#define TEST_MEM TEST_SIZE -#define TEST_LOOPS 10000 -#define TEST_TYPE_STR "" - -#ifndef TEST_SOURCES -# define TEST_SOURCES 16 -#endif -#ifndef RANDOMS -# define RANDOMS 20 -#endif - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j, rtest, srcs; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g3[TEST_SOURCES]; - u8 g4[TEST_SOURCES], g_tbls[4 * TEST_SOURCES * 32], *buffs[TEST_SOURCES]; - u8 *dest1, *dest2, *dest3, *dest4, *dest_ref1, *dest_ref2, *dest_ref3; - u8 *dest_ref4, *dest_ptrs[4]; - - int align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *udest_ptrs[4]; - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d ", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref4 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - dest_ptrs[2] = dest3; - dest_ptrs[3] = dest4; - - // Test of all zeros - for (i = 0; i < TEST_SOURCES; i++) - memset(buffs[i], 0, TEST_LEN); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest4, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - memset(dest_ref3, 0, TEST_LEN); - memset(dest_ref4, 0, TEST_LEN); - memset(g1, 2, TEST_SOURCES); - memset(g2, 1, TEST_SOURCES); - memset(g3, 7, TEST_SOURCES); - memset(g4, 3, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[32 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g3[i], &g_tbls[64 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g4[i], &g_tbls[96 * TEST_SOURCES + i * 32]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], buffs, - dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], buffs, - dest_ref4); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test3\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test4\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - - putchar('.'); - - // Rand data test - - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - buffs, dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], - buffs, dest_ref4); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test3 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test4 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - - putchar('.'); - } - - // Rand data test with varied parameters - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (srcs = TEST_SOURCES; srcs > 0; srcs--) { - for (i = 0; i < srcs; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[32 * srcs], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[64 * srcs], buffs, - dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[96 * srcs], buffs, - dest_ref4); - - FUNCTION_UNDER_TEST(TEST_LEN, srcs, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test1 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test2 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test3 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test4 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - - putchar('.'); - } - } - - // Run tests at end of buffer for Electric Fence - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 32; - for (size = TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[0], efence_buffs, dest_ref1); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - efence_buffs, dest_ref2); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - efence_buffs, dest_ref3); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], - efence_buffs, dest_ref4); - - FUNCTION_UNDER_TEST(size, TEST_SOURCES, g_tbls, efence_buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, align); - printf("dprod_dut:"); - dump(dest1, align); - return -1; - } - - if (0 != memcmp(dest_ref2, dest2, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, align); - printf("dprod_dut:"); - dump(dest2, align); - return -1; - } - - if (0 != memcmp(dest_ref3, dest3, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test3 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, align); - printf("dprod_dut:"); - dump(dest3, align); - return -1; - } - - if (0 != memcmp(dest_ref4, dest4, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test4 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, align); - printf("dprod_dut:"); - dump(dest4, align); - return -1; - } - - putchar('.'); - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~(TEST_MIN_SIZE - 1); - srcs = rand() % TEST_SOURCES; - if (srcs == 0) - continue; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < srcs; i++) - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - - udest_ptrs[0] = dest1 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[1] = dest2 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[2] = dest3 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[3] = dest4 + (rand() & (PTR_ALIGN_CHK_B - offset)); - - memset(dest1, 0, TEST_LEN); // zero pad to check write-over - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest4, 0, TEST_LEN); - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], ubuffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], ubuffs, dest_ref2); - gf_vect_dot_prod_base(size, srcs, &g_tbls[64 * srcs], ubuffs, dest_ref3); - gf_vect_dot_prod_base(size, srcs, &g_tbls[96 * srcs], ubuffs, dest_ref4); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptrs); - - if (memcmp(dest_ref1, udest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(udest_ptrs[0], 25); - return -1; - } - if (memcmp(dest_ref2, udest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(udest_ptrs[1], 25); - return -1; - } - if (memcmp(dest_ref3, udest_ptrs[2], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(udest_ptrs[2], 25); - return -1; - } - if (memcmp(dest_ref4, udest_ptrs[3], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(udest_ptrs[3], 25); - return -1; - } - // Confirm that padding around dests is unchanged - memset(dest_ref1, 0, PTR_ALIGN_CHK_B); // Make reference zero buff - offset = udest_ptrs[0] - dest1; - - if (memcmp(dest1, dest_ref1, offset)) { - printf("Fail rand ualign pad1 start\n"); - return -1; - } - if (memcmp(dest1 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad1 end\n"); - printf("size=%d offset=%d srcs=%d\n", size, offset, srcs); - return -1; - } - - offset = udest_ptrs[1] - dest2; - if (memcmp(dest2, dest_ref1, offset)) { - printf("Fail rand ualign pad2 start\n"); - return -1; - } - if (memcmp(dest2 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad2 end\n"); - return -1; - } - - offset = udest_ptrs[2] - dest3; - if (memcmp(dest3, dest_ref1, offset)) { - printf("Fail rand ualign pad3 start\n"); - return -1; - } - if (memcmp(dest3 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad3 end\n"); - return -1; - } - - offset = udest_ptrs[3] - dest4; - if (memcmp(dest4, dest_ref1, offset)) { - printf("Fail rand ualign pad4 start\n"); - return -1; - } - if (memcmp(dest4 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad4 end\n"); - return -1; - } - - putchar('.'); - } - - // Test all size alignment - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 32; - - for (size = TEST_LEN; size >= TEST_MIN_SIZE; size -= align) { - srcs = TEST_SOURCES; - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], buffs, dest_ref2); - gf_vect_dot_prod_base(size, srcs, &g_tbls[64 * srcs], buffs, dest_ref3); - gf_vect_dot_prod_base(size, srcs, &g_tbls[96 * srcs], buffs, dest_ref4); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest_ptrs); - - if (memcmp(dest_ref1, dest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest_ptrs[0], 25); - return -1; - } - if (memcmp(dest_ref2, dest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest_ptrs[1], 25); - return -1; - } - if (memcmp(dest_ref3, dest_ptrs[2], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest_ptrs[2], 25); - return -1; - } - if (memcmp(dest_ref4, dest_ptrs[3], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest_ptrs[3], 25); - return -1; - } - } - - printf("Pass\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse-perf.c b/pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse-perf.c deleted file mode 100644 index fc79c84fe..000000000 --- a/pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse-perf.c +++ /dev/null @@ -1,319 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_5vect_dot_prod_sse -#endif - -#define str(s) #s -#define xstr(s) str(s) - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 10 -# define TEST_LEN 8*1024 -# define TEST_LOOPS 40000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1)) -# define TEST_LOOPS 100 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g3[TEST_SOURCES]; - u8 g4[TEST_SOURCES], g5[TEST_SOURCES], *g_tbls, *buffs[TEST_SOURCES]; - u8 *dest1, *dest2, *dest3, *dest4, *dest5, *dest_ref1, *dest_ref2; - u8 *dest_ref3, *dest_ref4, *dest_ref5, *dest_ptrs[5]; - struct perf start, stop; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d\n", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 16, 6 * TEST_SOURCES * 32)) { - printf("alloc error: Fail"); - return -1; - } - g_tbls = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest5 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref5 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - dest_ptrs[2] = dest3; - dest_ptrs[3] = dest4; - dest_ptrs[4] = dest5; - - // Performance test - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest4, 0, TEST_LEN); - memset(dest5, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - memset(dest_ref3, 0, TEST_LEN); - memset(dest_ref4, 0, TEST_LEN); - memset(dest_ref5, 0, TEST_LEN); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - } - - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g4[j], &g_tbls[(96 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g5[j], &g_tbls[(128 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], buffs, - dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], buffs, - dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], buffs, - dest_ref5); - -#ifdef DO_REF_PERF - perf_start(&start); - for (i = 0; i < TEST_LOOPS / 20; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g4[j], &g_tbls[(96 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g5[j], &g_tbls[(128 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - buffs, dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], - buffs, dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], - buffs, dest_ref5); - } - perf_stop(&stop); - printf("gf_5vect_dot_prod_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 5) * i); -#endif - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g4[j], &g_tbls[(96 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g5[j], &g_tbls[(128 * TEST_SOURCES) + (j * 32)]); - } - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - } - perf_stop(&stop); - printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 5) * i); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test3\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test4\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - if (0 != memcmp(dest_ref5, dest5, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test5\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest5, 25); - return -1; - } - - printf("pass perf check\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse-test.c b/pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse-test.c deleted file mode 100644 index 4296f8b85..000000000 --- a/pkg/storage/erasure/isal/src/gf-5vect-dot-prod-sse-test.c +++ /dev/null @@ -1,805 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_5vect_dot_prod_sse -#endif -#ifndef TEST_MIN_SIZE -# define TEST_MIN_SIZE 16 -#endif - -#define str(s) #s -#define xstr(s) str(s) - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) -#define TEST_MEM TEST_SIZE -#define TEST_LOOPS 20000 -#define TEST_TYPE_STR "" - -#ifndef TEST_SOURCES -# define TEST_SOURCES 16 -#endif -#ifndef RANDOMS -# define RANDOMS 20 -#endif - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j, rtest, srcs; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g3[TEST_SOURCES]; - u8 g4[TEST_SOURCES], g5[TEST_SOURCES], *g_tbls; - u8 *dest1, *dest2, *dest3, *dest4, *dest5, *buffs[TEST_SOURCES]; - u8 *dest_ref1, *dest_ref2, *dest_ref3, *dest_ref4, *dest_ref5; - u8 *dest_ptrs[5]; - - int align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *udest_ptrs[5]; - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d ", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 16, 2 * (6 * TEST_SOURCES * 32))) { - printf("alloc error: Fail"); - return -1; - } - g_tbls = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest5 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref5 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - dest_ptrs[2] = dest3; - dest_ptrs[3] = dest4; - dest_ptrs[4] = dest5; - - // Test of all zeros - for (i = 0; i < TEST_SOURCES; i++) - memset(buffs[i], 0, TEST_LEN); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest4, 0, TEST_LEN); - memset(dest5, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - memset(dest_ref3, 0, TEST_LEN); - memset(dest_ref4, 0, TEST_LEN); - memset(dest_ref5, 0, TEST_LEN); - memset(g1, 2, TEST_SOURCES); - memset(g2, 1, TEST_SOURCES); - memset(g3, 7, TEST_SOURCES); - memset(g4, 9, TEST_SOURCES); - memset(g5, 4, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[32 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g3[i], &g_tbls[64 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g4[i], &g_tbls[96 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g5[i], &g_tbls[128 * TEST_SOURCES + i * 32]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], buffs, - dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], buffs, - dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], buffs, - dest_ref5); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test3\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test4\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - if (0 != memcmp(dest_ref5, dest5, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test5\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest5, 25); - return -1; - } - putchar('.'); - - // Rand data test - - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - buffs, dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], - buffs, dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], - buffs, dest_ref5); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test3 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test4 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - if (0 != memcmp(dest_ref5, dest5, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test5 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest5, 25); - return -1; - } - - putchar('.'); - } - - // Rand data test with varied parameters - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (srcs = TEST_SOURCES; srcs > 0; srcs--) { - for (i = 0; i < srcs; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * srcs) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[32 * srcs], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[64 * srcs], buffs, - dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[96 * srcs], buffs, - dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[128 * srcs], buffs, - dest_ref5); - - FUNCTION_UNDER_TEST(TEST_LEN, srcs, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test1 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test2 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test3 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test4 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - if (0 != memcmp(dest_ref5, dest5, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test5 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest5, 25); - return -1; - } - - putchar('.'); - } - } - - // Run tests at end of buffer for Electric Fence - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - for (size = TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[0], efence_buffs, dest_ref1); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - efence_buffs, dest_ref2); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - efence_buffs, dest_ref3); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], - efence_buffs, dest_ref4); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], - efence_buffs, dest_ref5); - - FUNCTION_UNDER_TEST(size, TEST_SOURCES, g_tbls, efence_buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, align); - printf("dprod_dut:"); - dump(dest1, align); - return -1; - } - - if (0 != memcmp(dest_ref2, dest2, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, align); - printf("dprod_dut:"); - dump(dest2, align); - return -1; - } - - if (0 != memcmp(dest_ref3, dest3, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test3 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, align); - printf("dprod_dut:"); - dump(dest3, align); - return -1; - } - - if (0 != memcmp(dest_ref4, dest4, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test4 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, align); - printf("dprod_dut:"); - dump(dest4, align); - return -1; - } - - if (0 != memcmp(dest_ref5, dest5, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test5 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, align); - printf("dprod_dut:"); - dump(dest5, align); - return -1; - } - - putchar('.'); - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~(TEST_MIN_SIZE - 1); - srcs = rand() % TEST_SOURCES; - if (srcs == 0) - continue; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < srcs; i++) - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - - udest_ptrs[0] = dest1 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[1] = dest2 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[2] = dest3 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[3] = dest4 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[4] = dest5 + (rand() & (PTR_ALIGN_CHK_B - offset)); - - memset(dest1, 0, TEST_LEN); // zero pad to check write-over - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest4, 0, TEST_LEN); - memset(dest5, 0, TEST_LEN); - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * srcs) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], ubuffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], ubuffs, dest_ref2); - gf_vect_dot_prod_base(size, srcs, &g_tbls[64 * srcs], ubuffs, dest_ref3); - gf_vect_dot_prod_base(size, srcs, &g_tbls[96 * srcs], ubuffs, dest_ref4); - gf_vect_dot_prod_base(size, srcs, &g_tbls[128 * srcs], ubuffs, dest_ref5); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptrs); - - if (memcmp(dest_ref1, udest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(udest_ptrs[0], 25); - return -1; - } - if (memcmp(dest_ref2, udest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(udest_ptrs[1], 25); - return -1; - } - if (memcmp(dest_ref3, udest_ptrs[2], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(udest_ptrs[2], 25); - return -1; - } - if (memcmp(dest_ref4, udest_ptrs[3], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(udest_ptrs[3], 25); - return -1; - } - if (memcmp(dest_ref5, udest_ptrs[4], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(udest_ptrs[4], 25); - return -1; - } - // Confirm that padding around dests is unchanged - memset(dest_ref1, 0, PTR_ALIGN_CHK_B); // Make reference zero buff - offset = udest_ptrs[0] - dest1; - - if (memcmp(dest1, dest_ref1, offset)) { - printf("Fail rand ualign pad1 start\n"); - return -1; - } - if (memcmp(dest1 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad1 end\n"); - return -1; - } - - offset = udest_ptrs[1] - dest2; - if (memcmp(dest2, dest_ref1, offset)) { - printf("Fail rand ualign pad2 start\n"); - return -1; - } - if (memcmp(dest2 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad2 end\n"); - return -1; - } - - offset = udest_ptrs[2] - dest3; - if (memcmp(dest3, dest_ref1, offset)) { - printf("Fail rand ualign pad3 start\n"); - return -1; - } - if (memcmp(dest3 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad3 end\n"); - return -1; - } - - offset = udest_ptrs[3] - dest4; - if (memcmp(dest4, dest_ref1, offset)) { - printf("Fail rand ualign pad4 start\n"); - return -1; - } - if (memcmp(dest4 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad4 end\n"); - return -1; - } - - offset = udest_ptrs[4] - dest5; - if (memcmp(dest5, dest_ref1, offset)) { - printf("Fail rand ualign pad5 start\n"); - return -1; - } - if (memcmp(dest5 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad5 end\n"); - return -1; - } - - putchar('.'); - } - - // Test all size alignment - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - - for (size = TEST_LEN; size >= TEST_MIN_SIZE; size -= align) { - srcs = TEST_SOURCES; - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * srcs) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], buffs, dest_ref2); - gf_vect_dot_prod_base(size, srcs, &g_tbls[64 * srcs], buffs, dest_ref3); - gf_vect_dot_prod_base(size, srcs, &g_tbls[96 * srcs], buffs, dest_ref4); - gf_vect_dot_prod_base(size, srcs, &g_tbls[128 * srcs], buffs, dest_ref5); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest_ptrs); - - if (memcmp(dest_ref1, dest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest_ptrs[0], 25); - - return -1; - } - if (memcmp(dest_ref2, dest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest_ptrs[1], 25); - return -1; - } - if (memcmp(dest_ref3, dest_ptrs[2], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest_ptrs[2], 25); - return -1; - } - if (memcmp(dest_ref4, dest_ptrs[3], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest_ptrs[3], 25); - return -1; - } - if (memcmp(dest_ref5, dest_ptrs[4], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest_ptrs[4], 25); - return -1; - } - } - - printf("Pass\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse-perf.c b/pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse-perf.c deleted file mode 100644 index e54b94e64..000000000 --- a/pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse-perf.c +++ /dev/null @@ -1,352 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_6vect_dot_prod_sse -#endif - -#define str(s) #s -#define xstr(s) str(s) - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 10 -# define TEST_LEN 8*1024 -# define TEST_LOOPS 40000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1)) -# define TEST_LOOPS 100 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g3[TEST_SOURCES]; - u8 g4[TEST_SOURCES], g5[TEST_SOURCES], g6[TEST_SOURCES], *g_tbls; - u8 *dest1, *dest2, *dest3, *dest4, *dest5, *dest6, *dest_ref1; - u8 *dest_ref2, *dest_ref3, *dest_ref4, *dest_ref5, *dest_ref6; - u8 *dest_ptrs[6], *buffs[TEST_SOURCES]; - struct perf start, stop; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d\n", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 16, 6 * TEST_SOURCES * 32)) { - printf("alloc error: Fail"); - return -1; - } - g_tbls = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest5 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest6 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref5 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref6 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - dest_ptrs[2] = dest3; - dest_ptrs[3] = dest4; - dest_ptrs[4] = dest5; - dest_ptrs[5] = dest6; - - // Performance test - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest4, 0, TEST_LEN); - memset(dest5, 0, TEST_LEN); - memset(dest6, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - memset(dest_ref3, 0, TEST_LEN); - memset(dest_ref4, 0, TEST_LEN); - memset(dest_ref5, 0, TEST_LEN); - memset(dest_ref6, 0, TEST_LEN); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - g6[i] = rand(); - } - - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g4[j], &g_tbls[(96 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g5[j], &g_tbls[(128 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g6[j], &g_tbls[(160 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], buffs, - dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], buffs, - dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], buffs, - dest_ref5); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[160 * TEST_SOURCES], buffs, - dest_ref6); - -#ifdef DO_REF_PERF - perf_start(&start); - for (i = 0; i < TEST_LOOPS / 20; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g4[j], &g_tbls[(96 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g5[j], &g_tbls[(128 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g6[j], &g_tbls[(160 * TEST_SOURCES) + (j * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - buffs, dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], - buffs, dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], - buffs, dest_ref5); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[160 * TEST_SOURCES], - buffs, dest_ref6); - } - perf_stop(&stop); - printf("gf_6vect_dot_prod_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 6) * i); -#endif - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) { - gf_vect_mul_init(g1[j], &g_tbls[j * 32]); - gf_vect_mul_init(g2[j], &g_tbls[(32 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g3[j], &g_tbls[(64 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g4[j], &g_tbls[(96 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g5[j], &g_tbls[(128 * TEST_SOURCES) + (j * 32)]); - gf_vect_mul_init(g6[j], &g_tbls[(160 * TEST_SOURCES) + (j * 32)]); - } - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - } - perf_stop(&stop); - printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 6) * i); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test3\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test4\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - if (0 != memcmp(dest_ref5, dest5, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test5\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest5, 25); - return -1; - } - if (0 != memcmp(dest_ref6, dest6, TEST_LEN)) { - printf("Fail perf " xstr(FUNCTION_UNDER_TEST) " test6\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref6, 25); - printf("dprod_dut:"); - dump(dest6, 25); - return -1; - } - - printf("pass perf check\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse-test.c b/pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse-test.c deleted file mode 100644 index d31fa6674..000000000 --- a/pkg/storage/erasure/isal/src/gf-6vect-dot-prod-sse-test.c +++ /dev/null @@ -1,911 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_6vect_dot_prod_sse -#endif -#ifndef TEST_MIN_SIZE -# define TEST_MIN_SIZE 16 -#endif - -#define str(s) #s -#define xstr(s) str(s) - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) -#define TEST_MEM TEST_SIZE -#define TEST_LOOPS 20000 -#define TEST_TYPE_STR "" - -#ifndef TEST_SOURCES -# define TEST_SOURCES 16 -#endif -#ifndef RANDOMS -# define RANDOMS 20 -#endif - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j, rtest, srcs; - void *buf; - u8 g1[TEST_SOURCES], g2[TEST_SOURCES], g3[TEST_SOURCES]; - u8 g4[TEST_SOURCES], g5[TEST_SOURCES], g6[TEST_SOURCES], *g_tbls; - u8 *dest1, *dest2, *dest3, *dest4, *dest5, *dest6, *dest_ref1; - u8 *dest_ref2, *dest_ref3, *dest_ref4, *dest_ref5, *dest_ref6; - u8 *dest_ptrs[6], *buffs[TEST_SOURCES]; - - int align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *udest_ptrs[6]; - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d ", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 16, 2 * (6 * TEST_SOURCES * 32))) { - printf("alloc error: Fail"); - return -1; - } - g_tbls = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest5 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest6 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref1 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref2 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref3 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref4 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref5 = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref6 = buf; - - dest_ptrs[0] = dest1; - dest_ptrs[1] = dest2; - dest_ptrs[2] = dest3; - dest_ptrs[3] = dest4; - dest_ptrs[4] = dest5; - dest_ptrs[5] = dest6; - - // Test of all zeros - for (i = 0; i < TEST_SOURCES; i++) - memset(buffs[i], 0, TEST_LEN); - - memset(dest1, 0, TEST_LEN); - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest4, 0, TEST_LEN); - memset(dest5, 0, TEST_LEN); - memset(dest6, 0, TEST_LEN); - memset(dest_ref1, 0, TEST_LEN); - memset(dest_ref2, 0, TEST_LEN); - memset(dest_ref3, 0, TEST_LEN); - memset(dest_ref4, 0, TEST_LEN); - memset(dest_ref5, 0, TEST_LEN); - memset(dest_ref6, 0, TEST_LEN); - memset(g1, 2, TEST_SOURCES); - memset(g2, 1, TEST_SOURCES); - memset(g3, 7, TEST_SOURCES); - memset(g4, 9, TEST_SOURCES); - memset(g5, 4, TEST_SOURCES); - memset(g6, 0xe6, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[32 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g3[i], &g_tbls[64 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g4[i], &g_tbls[96 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g5[i], &g_tbls[128 * TEST_SOURCES + i * 32]); - gf_vect_mul_init(g6[i], &g_tbls[160 * TEST_SOURCES + i * 32]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], buffs, - dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], buffs, - dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], buffs, - dest_ref5); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[160 * TEST_SOURCES], buffs, - dest_ref6); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test2\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test3\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test4\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - if (0 != memcmp(dest_ref5, dest5, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test5\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest5, 25); - return -1; - } - if (0 != memcmp(dest_ref6, dest6, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test6\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref6, 25); - printf("dprod_dut:"); - dump(dest6, 25); - return -1; - } - putchar('.'); - - // Rand data test - - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - g6[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g6[i], &g_tbls[(160 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - buffs, dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - buffs, dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], - buffs, dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], - buffs, dest_ref5); - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[160 * TEST_SOURCES], - buffs, dest_ref6); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test3 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test4 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - if (0 != memcmp(dest_ref5, dest5, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test5 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest5, 25); - return -1; - } - if (0 != memcmp(dest_ref6, dest6, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test6 %d\n", rtest); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref6, 25); - printf("dprod_dut:"); - dump(dest6, 25); - return -1; - } - - putchar('.'); - } - - // Rand data test with varied parameters - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (srcs = TEST_SOURCES; srcs > 0; srcs--) { - for (i = 0; i < srcs; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - g6[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * srcs) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * srcs) + (i * 32)]); - gf_vect_mul_init(g6[i], &g_tbls[(160 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[32 * srcs], buffs, - dest_ref2); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[64 * srcs], buffs, - dest_ref3); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[96 * srcs], buffs, - dest_ref4); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[128 * srcs], buffs, - dest_ref5); - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[160 * srcs], buffs, - dest_ref6); - - FUNCTION_UNDER_TEST(TEST_LEN, srcs, g_tbls, buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test1 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest1, 25); - return -1; - } - if (0 != memcmp(dest_ref2, dest2, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test2 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest2, 25); - return -1; - } - if (0 != memcmp(dest_ref3, dest3, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test3 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest3, 25); - return -1; - } - if (0 != memcmp(dest_ref4, dest4, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test4 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest4, 25); - return -1; - } - if (0 != memcmp(dest_ref5, dest5, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test5 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest5, 25); - return -1; - } - if (0 != memcmp(dest_ref6, dest6, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) - " test6 srcs=%d\n", srcs); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref6, 25); - printf("dprod_dut:"); - dump(dest6, 25); - return -1; - } - - putchar('.'); - } - } - - // Run tests at end of buffer for Electric Fence - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - for (size = TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - - for (i = 0; i < TEST_SOURCES; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - g6[i] = rand(); - } - - for (i = 0; i < TEST_SOURCES; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * TEST_SOURCES) + (i * 32)]); - gf_vect_mul_init(g6[i], &g_tbls[(160 * TEST_SOURCES) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[0], efence_buffs, dest_ref1); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[32 * TEST_SOURCES], - efence_buffs, dest_ref2); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[64 * TEST_SOURCES], - efence_buffs, dest_ref3); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[96 * TEST_SOURCES], - efence_buffs, dest_ref4); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[128 * TEST_SOURCES], - efence_buffs, dest_ref5); - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[160 * TEST_SOURCES], - efence_buffs, dest_ref6); - - FUNCTION_UNDER_TEST(size, TEST_SOURCES, g_tbls, efence_buffs, dest_ptrs); - - if (0 != memcmp(dest_ref1, dest1, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test1 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, align); - printf("dprod_dut:"); - dump(dest1, align); - return -1; - } - - if (0 != memcmp(dest_ref2, dest2, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test2 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, align); - printf("dprod_dut:"); - dump(dest2, align); - return -1; - } - - if (0 != memcmp(dest_ref3, dest3, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test3 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, align); - printf("dprod_dut:"); - dump(dest3, align); - return -1; - } - - if (0 != memcmp(dest_ref4, dest4, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test4 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, align); - printf("dprod_dut:"); - dump(dest4, align); - return -1; - } - - if (0 != memcmp(dest_ref5, dest5, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test5 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, align); - printf("dprod_dut:"); - dump(dest5, align); - return -1; - } - - if (0 != memcmp(dest_ref6, dest6, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test6 %d\n", rtest); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref6, align); - printf("dprod_dut:"); - dump(dest6, align); - return -1; - } - - putchar('.'); - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~(TEST_MIN_SIZE - 1); - srcs = rand() % TEST_SOURCES; - if (srcs == 0) - continue; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < srcs; i++) - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - - udest_ptrs[0] = dest1 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[1] = dest2 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[2] = dest3 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[3] = dest4 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[4] = dest5 + (rand() & (PTR_ALIGN_CHK_B - offset)); - udest_ptrs[5] = dest6 + (rand() & (PTR_ALIGN_CHK_B - offset)); - - memset(dest1, 0, TEST_LEN); // zero pad to check write-over - memset(dest2, 0, TEST_LEN); - memset(dest3, 0, TEST_LEN); - memset(dest4, 0, TEST_LEN); - memset(dest5, 0, TEST_LEN); - memset(dest6, 0, TEST_LEN); - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - g6[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * srcs) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * srcs) + (i * 32)]); - gf_vect_mul_init(g6[i], &g_tbls[(160 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], ubuffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], ubuffs, dest_ref2); - gf_vect_dot_prod_base(size, srcs, &g_tbls[64 * srcs], ubuffs, dest_ref3); - gf_vect_dot_prod_base(size, srcs, &g_tbls[96 * srcs], ubuffs, dest_ref4); - gf_vect_dot_prod_base(size, srcs, &g_tbls[128 * srcs], ubuffs, dest_ref5); - gf_vect_dot_prod_base(size, srcs, &g_tbls[160 * srcs], ubuffs, dest_ref6); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptrs); - - if (memcmp(dest_ref1, udest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(udest_ptrs[0], 25); - return -1; - } - if (memcmp(dest_ref2, udest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(udest_ptrs[1], 25); - return -1; - } - if (memcmp(dest_ref3, udest_ptrs[2], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(udest_ptrs[2], 25); - return -1; - } - if (memcmp(dest_ref4, udest_ptrs[3], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(udest_ptrs[3], 25); - return -1; - } - if (memcmp(dest_ref5, udest_ptrs[4], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(udest_ptrs[4], 25); - return -1; - } - if (memcmp(dest_ref6, udest_ptrs[5], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref6, 25); - printf("dprod_dut:"); - dump(udest_ptrs[5], 25); - return -1; - } - // Confirm that padding around dests is unchanged - memset(dest_ref1, 0, PTR_ALIGN_CHK_B); // Make reference zero buff - offset = udest_ptrs[0] - dest1; - - if (memcmp(dest1, dest_ref1, offset)) { - printf("Fail rand ualign pad1 start\n"); - return -1; - } - if (memcmp(dest1 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad1 end\n"); - return -1; - } - - offset = udest_ptrs[1] - dest2; - if (memcmp(dest2, dest_ref1, offset)) { - printf("Fail rand ualign pad2 start\n"); - return -1; - } - if (memcmp(dest2 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad2 end\n"); - return -1; - } - - offset = udest_ptrs[2] - dest3; - if (memcmp(dest3, dest_ref1, offset)) { - printf("Fail rand ualign pad3 start\n"); - return -1; - } - if (memcmp(dest3 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad3 end\n"); - return -1; - } - - offset = udest_ptrs[3] - dest4; - if (memcmp(dest4, dest_ref1, offset)) { - printf("Fail rand ualign pad4 start\n"); - return -1; - } - if (memcmp(dest4 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad4 end\n"); - return -1; - } - - offset = udest_ptrs[4] - dest5; - if (memcmp(dest5, dest_ref1, offset)) { - printf("Fail rand ualign pad5 start\n"); - return -1; - } - if (memcmp(dest5 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad5 end\n"); - return -1; - } - - offset = udest_ptrs[5] - dest6; - if (memcmp(dest6, dest_ref1, offset)) { - printf("Fail rand ualign pad6 start\n"); - return -1; - } - if (memcmp(dest6 + offset + size, dest_ref1, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad6 end\n"); - return -1; - } - - putchar('.'); - } - - // Test all size alignment - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - - for (size = TEST_LEN; size >= TEST_MIN_SIZE; size -= align) { - srcs = TEST_SOURCES; - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) { - g1[i] = rand(); - g2[i] = rand(); - g3[i] = rand(); - g4[i] = rand(); - g5[i] = rand(); - g6[i] = rand(); - } - - for (i = 0; i < srcs; i++) { - gf_vect_mul_init(g1[i], &g_tbls[i * 32]); - gf_vect_mul_init(g2[i], &g_tbls[(32 * srcs) + (i * 32)]); - gf_vect_mul_init(g3[i], &g_tbls[(64 * srcs) + (i * 32)]); - gf_vect_mul_init(g4[i], &g_tbls[(96 * srcs) + (i * 32)]); - gf_vect_mul_init(g5[i], &g_tbls[(128 * srcs) + (i * 32)]); - gf_vect_mul_init(g6[i], &g_tbls[(160 * srcs) + (i * 32)]); - } - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], buffs, dest_ref1); - gf_vect_dot_prod_base(size, srcs, &g_tbls[32 * srcs], buffs, dest_ref2); - gf_vect_dot_prod_base(size, srcs, &g_tbls[64 * srcs], buffs, dest_ref3); - gf_vect_dot_prod_base(size, srcs, &g_tbls[96 * srcs], buffs, dest_ref4); - gf_vect_dot_prod_base(size, srcs, &g_tbls[128 * srcs], buffs, dest_ref5); - gf_vect_dot_prod_base(size, srcs, &g_tbls[160 * srcs], buffs, dest_ref6); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest_ptrs); - - if (memcmp(dest_ref1, dest_ptrs[0], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref1, 25); - printf("dprod_dut:"); - dump(dest_ptrs[0], 25); - return -1; - } - if (memcmp(dest_ref2, dest_ptrs[1], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref2, 25); - printf("dprod_dut:"); - dump(dest_ptrs[1], 25); - return -1; - } - if (memcmp(dest_ref3, dest_ptrs[2], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref3, 25); - printf("dprod_dut:"); - dump(dest_ptrs[2], 25); - return -1; - } - if (memcmp(dest_ref4, dest_ptrs[3], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref4, 25); - printf("dprod_dut:"); - dump(dest_ptrs[3], 25); - return -1; - } - if (memcmp(dest_ref5, dest_ptrs[4], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref5, 25); - printf("dprod_dut:"); - dump(dest_ptrs[4], 25); - return -1; - } - if (memcmp(dest_ref6, dest_ptrs[5], size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref6, 25); - printf("dprod_dut:"); - dump(dest_ptrs[5], 25); - return -1; - } - } - - printf("Pass\n"); - return 0; - -} diff --git a/pkg/storage/erasure/isal/src/gf-inverse-test.c b/pkg/storage/erasure/isal/src/gf-inverse-test.c deleted file mode 100644 index 52e3a78d0..000000000 --- a/pkg/storage/erasure/isal/src/gf-inverse-test.c +++ /dev/null @@ -1,225 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include - -#include "erasure-code.h" - -#define TEST_LEN 8192 - -#ifndef TEST_SOURCES -# define TEST_SOURCES 128 -#endif -#ifndef RANDOMS -# define RANDOMS 200 -#endif - -#define KMAX TEST_SOURCES - -typedef unsigned char u8; - -void matrix_mult(u8 * a, u8 * b, u8 * c, int n) -{ - int i, j, k; - u8 d; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - d = 0; - for (k = 0; k < n; k++) { - d ^= gf_mul(a[n * i + k], b[n * k + j]); - } - c[i * n + j] = d; - } - } -} - -void print_matrix(u8 * a, int n) -{ - int i, j; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - printf(" %2x", a[i * n + j]); - } - printf("\n"); - } - printf("\n"); -} - -int is_ident(u8 * a, const int n) -{ - int i, j; - u8 c; - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - c = *a++; - if (i == j) - c--; - if (c != 0) - return -1; - } - } - return 0; -} - -int inv_test(u8 * in, u8 * inv, u8 * sav, int n) -{ - memcpy(sav, in, n * n); - - if (gf_invert_matrix(in, inv, n)) { - printf("Given singular matrix\n"); - print_matrix(sav, n); - return -1; - } - - matrix_mult(inv, sav, in, n); - - if (is_ident(in, n)) { - printf("fail\n"); - print_matrix(sav, n); - print_matrix(inv, n); - print_matrix(in, n); - return -1; - } - putchar('.'); - - return 0; -} - -int main(int argc, char *argv[]) -{ - int i, k, t; - u8 *test_mat, *save_mat, *invr_mat; - - u8 test1[] = { 1, 1, 6, - 1, 1, 1, - 7, 1, 9 - }; - - u8 test2[] = { 0, 1, 6, - 1, 0, 1, - 0, 1, 9 - }; - - u8 test3[] = { 0, 0, 1, - 1, 0, 0, - 0, 1, 1 - }; - - u8 test4[] = { 0, 1, 6, 7, - 1, 1, 0, 0, - 0, 1, 2, 3, - 3, 2, 2, 3 - }; // = row3+3*row2 - - printf("gf_inverse_test: max=%d ", KMAX); - - test_mat = malloc(KMAX * KMAX); - save_mat = malloc(KMAX * KMAX); - invr_mat = malloc(KMAX * KMAX); - - if (NULL == test_mat || NULL == save_mat || NULL == invr_mat) - return -1; - - // Test with lots of leading 1's - k = 3; - memcpy(test_mat, test1, k * k); - if (inv_test(test_mat, invr_mat, save_mat, k)) - return -1; - - // Test with leading zeros - k = 3; - memcpy(test_mat, test2, k * k); - if (inv_test(test_mat, invr_mat, save_mat, k)) - return -1; - - // Test 3 - k = 3; - memcpy(test_mat, test3, k * k); - if (inv_test(test_mat, invr_mat, save_mat, k)) - return -1; - - // Test 4 - try a singular matrix - k = 4; - memcpy(test_mat, test4, k * k); - if (!gf_invert_matrix(test_mat, invr_mat, k)) { - printf("Fail: didn't catch singular matrix\n"); - print_matrix(test4, 4); - return -1; - } - // Do random test of size KMAX - k = KMAX; - - for (i = 0; i < k * k; i++) - test_mat[i] = save_mat[i] = rand(); - - if (gf_invert_matrix(test_mat, invr_mat, k)) { - printf("rand picked a singular matrix, try again\n"); - return -1; - } - - matrix_mult(invr_mat, save_mat, test_mat, k); - - if (is_ident(test_mat, k)) { - printf("fail\n"); - print_matrix(save_mat, k); - print_matrix(invr_mat, k); - print_matrix(test_mat, k); - return -1; - } - // Do Randoms. Random size and coefficients - for (t = 0; t < RANDOMS; t++) { - k = rand() % KMAX; - - for (i = 0; i < k * k; i++) - test_mat[i] = save_mat[i] = rand(); - - if (gf_invert_matrix(test_mat, invr_mat, k)) - continue; - - matrix_mult(invr_mat, save_mat, test_mat, k); - - if (is_ident(test_mat, k)) { - printf("fail rand k=%d\n", k); - print_matrix(save_mat, k); - print_matrix(invr_mat, k); - print_matrix(test_mat, k); - return -1; - } - if (0 == (t % 8)) - putchar('.'); - } - - printf(" Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-1tbl.c b/pkg/storage/erasure/isal/src/gf-vect-dot-prod-1tbl.c deleted file mode 100644 index b04d6f50f..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-1tbl.c +++ /dev/null @@ -1,166 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure/tests.h" -#include "erasure-code.h" - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 10 -# define TEST_LEN 8*1024 -# define TEST_LOOPS 4000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN GT_L3_CACHE / TEST_SOURCES -# define TEST_LOOPS 10 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -typedef unsigned char u8; - -// Global GF(256) tables -u8 gff[256]; -u8 gflog[256]; -u8 gf_mul_table[256 * 256]; - -void mk_gf_field() -{ - int i; - u8 s = 1; - gflog[0] = 0; - - for (i = 0; i < 256; i++) { - gff[i] = s; - gflog[s] = i; - s = (s << 1) ^ ((s & 0x80) ? 0x1d : 0); // mult by GF{2} - } -} - -void mk_gf_mul_table(u8 * table) -{ - // Populate a single table with all multiply combinations for a fast, - // single-table lookup of GF(2^8) multiply at the expense of memory. - int i, j; - for (i = 0; i < 256; i++) - for (j = 0; j < 256; j++) - table[i * 256 + j] = gf_mul(i, j); -} - -void gf_vect_dot_prod_ref(int len, int vlen, u8 * v, u8 ** src, u8 * dest) -{ - int i, j; - u8 s; - for (i = 0; i < len; i++) { - s = 0; - for (j = 0; j < vlen; j++) - s ^= gf_mul(src[j][i], v[j]); - - dest[i] = s; - } -} - -int main() -{ - int i, j, k; - u8 s, vec[TEST_SOURCES], dest1[TEST_LEN], dest2[TEST_LEN]; - u8 *matrix[TEST_SOURCES]; - struct perf start, stop; - - mk_gf_field(); - mk_gf_mul_table(gf_mul_table); - - //generate random vector and matrix/data - for (i = 0; i < TEST_SOURCES; i++) { - vec[i] = rand(); - - if (!(matrix[i] = malloc(TEST_LEN))) { - fprintf(stderr, "Error failure\n\n"); - return -1; - } - for (j = 0; j < TEST_LEN; j++) - matrix[i][j] = rand(); - - } - - gf_vect_dot_prod_ref(TEST_LEN, TEST_SOURCES, vec, matrix, dest1); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) - gf_vect_dot_prod_ref(TEST_LEN, TEST_SOURCES, vec, matrix, dest1); - - perf_stop(&stop); - printf("gf_vect_dot_prod_2tbl" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); - - // Warm up mult tables - for (i = 0; i < TEST_LEN; i++) { - s = 0; - for (j = 0; j < TEST_SOURCES; j++) { - s ^= gf_mul_table[vec[j] * 256 + matrix[j][i]]; - } - dest2[i] = s; - } - - perf_start(&start); - for (k = 0; k < TEST_LOOPS; k++) { - for (i = 0; i < TEST_LEN; i++) { - s = 0; - for (j = 0; j < TEST_SOURCES; j++) { - s ^= gf_mul_table[vec[j] * 256 + matrix[j][i]]; - } - dest2[i] = s; - } - } - perf_stop(&stop); - printf("gf_vect_dot_prod_1tbl" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * k); - - // Compare with reference function - if (0 != memcmp(dest1, dest2, TEST_LEN)) { - printf("Error, different results!\n\n"); - return -1; - } - - printf("Pass functional test\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx-perf.c b/pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx-perf.c deleted file mode 100644 index 2c0ea631c..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx-perf.c +++ /dev/null @@ -1,184 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_vect_dot_prod_avx -#endif - -#define str(s) #s -#define xstr(s) str(s) - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 10 -# define TEST_LEN 8*1024 -# define TEST_LOOPS 40000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1)) -# define TEST_LOOPS 100 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j; - void *buf; - u8 g[TEST_SOURCES], g_tbls[TEST_SOURCES * 32], *dest, *dest_ref; - u8 *temp_buff, *buffs[TEST_SOURCES]; - struct perf start, stop; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d\n", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buff = buf; - - // Performance test - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - memset(dest, 0, TEST_LEN); - memset(temp_buff, 0, TEST_LEN); - memset(dest_ref, 0, TEST_LEN); - memset(g, 0, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) - g[i] = rand(); - - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - -#ifdef DO_REF_PERF - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - } - perf_stop(&stop); - printf("gf_vect_dot_prod_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); -#endif - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - } - perf_stop(&stop); - printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } - - printf("pass perf check\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx-test.c b/pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx-test.c deleted file mode 100644 index 614747bfe..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-avx-test.c +++ /dev/null @@ -1,525 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_vect_dot_prod_avx -#endif -#ifndef TEST_MIN_SIZE -# define TEST_MIN_SIZE 16 -#endif - -#define str(s) #s -#define xstr(s) str(s) - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) - -#ifndef TEST_SOURCES -# define TEST_SOURCES 16 -#endif -#ifndef RANDOMS -# define RANDOMS 20 -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j, rtest, srcs, m, k, nerrs, r, err; - void *buf; - u8 g[TEST_SOURCES], g_tbls[TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; - u8 *dest, *dest_ref, *temp_buff, *buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], d[MMAX * KMAX]; - u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - - int align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *udest_ptr; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d ", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buff = buf; - - // Test of all zeros - for (i = 0; i < TEST_SOURCES; i++) - memset(buffs[i], 0, TEST_LEN); - - memset(dest, 0, TEST_LEN); - memset(temp_buff, 0, TEST_LEN); - memset(dest_ref, 0, TEST_LEN); - memset(g, 0, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " \n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } else - putchar('.'); - - // Rand data test - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) - g[i] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " 1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } - - putchar('.'); - } - - // Rand data test with varied parameters - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (srcs = TEST_SOURCES; srcs > 0; srcs--) { - for (i = 0; i < srcs; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) - g[i] = rand(); - - for (i = 0; i < srcs; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[0], buffs, dest_ref); - FUNCTION_UNDER_TEST(TEST_LEN, srcs, g_tbls, buffs, dest); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test 2\n"); - dump_matrix(buffs, 5, srcs); - printf("dprod_base:"); - dump(dest_ref, 5); - printf("dprod:"); - dump(dest, 5); - return -1; - } - - putchar('.'); - } - } - - // Test erasure code using gf_vect_dot_prod - - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - gf_gen_rs_matrix(a, m, k); - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Make parity vects - for (i = k; i < m; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(a[k * i + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, buffs, buffs[i]); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], buffs, buffs[i]); -#endif - } - - // Random buffers in erasure - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0, nerrs = 0; i < k && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) - src_err_list[nerrs++] = i; - } - - // construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix((u8 *) b, (u8 *) d, k) < 0) - printf("BAD MATRIX\n"); - - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - recov[i] = buffs[r]; - } - - // Recover data - for (i = 0; i < nerrs; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(d[k * src_err_list[i] + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, recov, temp_buff); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], recov, temp_buff); -#endif - - if (0 != memcmp(temp_buff, buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf("recov %d:", src_err_list[i]); - dump(temp_buff, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Do more random tests - - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - gf_gen_rs_matrix(a, m, k); - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Make parity vects - for (i = k; i < m; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(a[k * i + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, buffs, buffs[i]); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], buffs, buffs[i]); -#endif - } - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0, nerrs = 0; i < k && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) - src_err_list[nerrs++] = i; - } - if (nerrs == 0) { // should have at least one error - while ((err = (rand() % KMAX)) >= k) ; - src_err_list[nerrs++] = err; - src_in_err[err] = 1; - } - // construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix((u8 *) b, (u8 *) d, k) < 0) - printf("BAD MATRIX\n"); - - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - recov[i] = buffs[r]; - } - - // Recover data - for (i = 0; i < nerrs; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(d[k * src_err_list[i] + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, recov, temp_buff); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], recov, temp_buff); -#endif - if (0 != memcmp(temp_buff, buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (i = 0; i < nerrs; i++) - printf(" %d", src_err_list[i]); - printf("\na:\n"); - dump_u8xu8((u8 *) a, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) d, k, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buff, 25); - return -1; - } - } - putchar('.'); - } - - // Run tests at end of buffer for Electric Fence - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - for (size = TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - - for (i = 0; i < TEST_SOURCES; i++) - g[i] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[0], efence_buffs, dest_ref); - FUNCTION_UNDER_TEST(size, TEST_SOURCES, g_tbls, efence_buffs, dest); - - if (0 != memcmp(dest_ref, dest, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test 3\n"); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, align); - printf("dprod:"); - dump(dest, align); - return -1; - } - - putchar('.'); - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~(TEST_MIN_SIZE - 1); - srcs = rand() % TEST_SOURCES; - if (srcs == 0) - continue; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < srcs; i++) - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - - udest_ptr = dest + (rand() & (PTR_ALIGN_CHK_B - offset)); - - memset(dest, 0, TEST_LEN); // zero pad to check write-over - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) - g[i] = rand(); - - for (i = 0; i < srcs; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], ubuffs, dest_ref); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptr); - - if (memcmp(dest_ref, udest_ptr, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(udest_ptr, 25); - return -1; - } - // Confirm that padding around dests is unchanged - memset(dest_ref, 0, PTR_ALIGN_CHK_B); // Make reference zero buff - offset = udest_ptr - dest; - - if (memcmp(dest, dest_ref, offset)) { - printf("Fail rand ualign pad start\n"); - return -1; - } - if (memcmp(dest + offset + size, dest_ref, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad end\n"); - return -1; - } - - putchar('.'); - } - - // Test all size alignment - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - - for (size = TEST_LEN; size >= TEST_MIN_SIZE; size -= align) { - srcs = TEST_SOURCES; - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) - g[i] = rand(); - - for (i = 0; i < srcs; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], buffs, dest_ref); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest); - - if (memcmp(dest_ref, dest, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } - } - - printf("done all: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-base-test.c b/pkg/storage/erasure/isal/src/gf-vect-dot-prod-base-test.c deleted file mode 100644 index 33a62f0bf..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-base-test.c +++ /dev/null @@ -1,290 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) - -#ifndef TEST_SOURCES -# define TEST_SOURCES 250 -#endif -#ifndef RANDOMS -# define RANDOMS 20 -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j, rtest, m, k, nerrs, r, err; - void *buf; - u8 g[TEST_SOURCES], g_tbls[TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; - u8 *dest, *dest_ref, *temp_buff, *buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], d[MMAX * KMAX]; - u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - - printf("gf_vect_dot_prod_base: %dx%d ", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buff = buf; - - // Init - for (i = 0; i < TEST_SOURCES; i++) - memset(buffs[i], 0, TEST_LEN); - - memset(dest, 0, TEST_LEN); - memset(temp_buff, 0, TEST_LEN); - memset(dest_ref, 0, TEST_LEN); - memset(g, 0, TEST_SOURCES); - - // Test erasure code using gf_vect_dot_prod - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - gf_gen_cauchy1_matrix(a, m, k); - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Make parity vects - for (i = k; i < m; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(a[k * i + j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, k, g_tbls, buffs, buffs[i]); - } - - // Random buffers in erasure - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0, nerrs = 0; i < k && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) - src_err_list[nerrs++] = i; - } - - // construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix((u8 *) b, (u8 *) d, k) < 0) - printf("BAD MATRIX\n"); - - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - recov[i] = buffs[r]; - } - - // Recover data - for (i = 0; i < nerrs; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(d[k * src_err_list[i] + j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, k, g_tbls, recov, temp_buff); - - if (0 != memcmp(temp_buff, buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf("recov %d:", src_err_list[i]); - dump(temp_buff, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Do more random tests - - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - gf_gen_cauchy1_matrix(a, m, k); - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Make parity vects - for (i = k; i < m; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(a[k * i + j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, k, g_tbls, buffs, buffs[i]); - } - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0, nerrs = 0; i < k && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) - src_err_list[nerrs++] = i; - } - if (nerrs == 0) { // should have at least one error - while ((err = (rand() % KMAX)) >= k) ; - src_err_list[nerrs++] = err; - src_in_err[err] = 1; - } - // construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix((u8 *) b, (u8 *) d, k) < 0) - printf("BAD MATRIX\n"); - - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - recov[i] = buffs[r]; - } - - // Recover data - for (i = 0; i < nerrs; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(d[k * src_err_list[i] + j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, k, g_tbls, recov, temp_buff); - - if (0 != memcmp(temp_buff, buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (i = 0; i < nerrs; i++) - printf(" %d", src_err_list[i]); - printf("\na:\n"); - dump_u8xu8((u8 *) a, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) d, k, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buff, 25); - return -1; - } - } - putchar('.'); - } - - printf("done all: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-perf.c b/pkg/storage/erasure/isal/src/gf-vect-dot-prod-perf.c deleted file mode 100644 index 410221099..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-perf.c +++ /dev/null @@ -1,184 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_vect_dot_prod -#endif - -#define str(s) #s -#define xstr(s) str(s) - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 10 -# define TEST_LEN 8*1024 -# define TEST_LOOPS 40000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1)) -# define TEST_LOOPS 100 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j; - void *buf; - u8 g[TEST_SOURCES], g_tbls[TEST_SOURCES * 32], *dest, *dest_ref; - u8 *temp_buff, *buffs[TEST_SOURCES]; - struct perf start, stop; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d\n", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buff = buf; - - // Performance test - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - memset(dest, 0, TEST_LEN); - memset(temp_buff, 0, TEST_LEN); - memset(dest_ref, 0, TEST_LEN); - memset(g, 0, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) - g[i] = rand(); - - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - -#ifdef DO_REF_PERF - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - } - perf_stop(&stop); - printf("gf_vect_dot_prod_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); -#endif - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - } - perf_stop(&stop); - printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } - - printf("pass perf check\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse-perf.c b/pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse-perf.c deleted file mode 100644 index 1eb9a43b2..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse-perf.c +++ /dev/null @@ -1,184 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/tests.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_vect_dot_prod_sse -#endif - -#define str(s) #s -#define xstr(s) str(s) - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_SOURCES 10 -# define TEST_LEN 8*1024 -# define TEST_LOOPS 40000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1)) -# define TEST_LOOPS 100 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j; - void *buf; - u8 g[TEST_SOURCES], g_tbls[TEST_SOURCES * 32], *dest, *dest_ref; - u8 *temp_buff, *buffs[TEST_SOURCES]; - struct perf start, stop; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d\n", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buff = buf; - - // Performance test - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - memset(dest, 0, TEST_LEN); - memset(temp_buff, 0, TEST_LEN); - memset(dest_ref, 0, TEST_LEN); - memset(g, 0, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) - g[i] = rand(); - - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - -#ifdef DO_REF_PERF - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - } - perf_stop(&stop); - printf("gf_vect_dot_prod_base" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); -#endif - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - for (j = 0; j < TEST_SOURCES; j++) - gf_vect_mul_init(g[j], &g_tbls[j * 32]); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - } - perf_stop(&stop); - printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * (TEST_SOURCES + 1) * i); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } - - printf("pass perf check\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse-test.c b/pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse-test.c deleted file mode 100644 index 461042344..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-sse-test.c +++ /dev/null @@ -1,525 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_vect_dot_prod_sse -#endif -#ifndef TEST_MIN_SIZE -# define TEST_MIN_SIZE 16 -#endif - -#define str(s) #s -#define xstr(s) str(s) - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) - -#ifndef TEST_SOURCES -# define TEST_SOURCES 16 -#endif -#ifndef RANDOMS -# define RANDOMS 20 -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j, rtest, srcs, m, k, nerrs, r, err; - void *buf; - u8 g[TEST_SOURCES], g_tbls[TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; - u8 *dest, *dest_ref, *temp_buff, *buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], d[MMAX * KMAX]; - u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - - int align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *udest_ptr; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d ", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buff = buf; - - // Test of all zeros - for (i = 0; i < TEST_SOURCES; i++) - memset(buffs[i], 0, TEST_LEN); - - memset(dest, 0, TEST_LEN); - memset(temp_buff, 0, TEST_LEN); - memset(dest_ref, 0, TEST_LEN); - memset(g, 0, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " \n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } else - putchar('.'); - - // Rand data test - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) - g[i] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " 1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } - - putchar('.'); - } - - // Rand data test with varied parameters - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (srcs = TEST_SOURCES; srcs > 0; srcs--) { - for (i = 0; i < srcs; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) - g[i] = rand(); - - for (i = 0; i < srcs; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[0], buffs, dest_ref); - FUNCTION_UNDER_TEST(TEST_LEN, srcs, g_tbls, buffs, dest); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test 2\n"); - dump_matrix(buffs, 5, srcs); - printf("dprod_base:"); - dump(dest_ref, 5); - printf("dprod:"); - dump(dest, 5); - return -1; - } - - putchar('.'); - } - } - - // Test erasure code using gf_vect_dot_prod - - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - gf_gen_rs_matrix(a, m, k); - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Make parity vects - for (i = k; i < m; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(a[k * i + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, buffs, buffs[i]); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], buffs, buffs[i]); -#endif - } - - // Random buffers in erasure - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0, nerrs = 0; i < k && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) - src_err_list[nerrs++] = i; - } - - // construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix((u8 *) b, (u8 *) d, k) < 0) - printf("BAD MATRIX\n"); - - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - recov[i] = buffs[r]; - } - - // Recover data - for (i = 0; i < nerrs; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(d[k * src_err_list[i] + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, recov, temp_buff); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], recov, temp_buff); -#endif - - if (0 != memcmp(temp_buff, buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf("recov %d:", src_err_list[i]); - dump(temp_buff, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Do more random tests - - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - gf_gen_rs_matrix(a, m, k); - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Make parity vects - for (i = k; i < m; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(a[k * i + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, buffs, buffs[i]); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], buffs, buffs[i]); -#endif - } - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0, nerrs = 0; i < k && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) - src_err_list[nerrs++] = i; - } - if (nerrs == 0) { // should have at least one error - while ((err = (rand() % KMAX)) >= k) ; - src_err_list[nerrs++] = err; - src_in_err[err] = 1; - } - // construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix((u8 *) b, (u8 *) d, k) < 0) - printf("BAD MATRIX\n"); - - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - recov[i] = buffs[r]; - } - - // Recover data - for (i = 0; i < nerrs; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(d[k * src_err_list[i] + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, recov, temp_buff); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], recov, temp_buff); -#endif - if (0 != memcmp(temp_buff, buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (i = 0; i < nerrs; i++) - printf(" %d", src_err_list[i]); - printf("\na:\n"); - dump_u8xu8((u8 *) a, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) d, k, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buff, 25); - return -1; - } - } - putchar('.'); - } - - // Run tests at end of buffer for Electric Fence - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - for (size = TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - - for (i = 0; i < TEST_SOURCES; i++) - g[i] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[0], efence_buffs, dest_ref); - FUNCTION_UNDER_TEST(size, TEST_SOURCES, g_tbls, efence_buffs, dest); - - if (0 != memcmp(dest_ref, dest, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test 3\n"); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, align); - printf("dprod:"); - dump(dest, align); - return -1; - } - - putchar('.'); - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~(TEST_MIN_SIZE - 1); - srcs = rand() % TEST_SOURCES; - if (srcs == 0) - continue; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < srcs; i++) - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - - udest_ptr = dest + (rand() & (PTR_ALIGN_CHK_B - offset)); - - memset(dest, 0, TEST_LEN); // zero pad to check write-over - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) - g[i] = rand(); - - for (i = 0; i < srcs; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], ubuffs, dest_ref); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptr); - - if (memcmp(dest_ref, udest_ptr, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(udest_ptr, 25); - return -1; - } - // Confirm that padding around dests is unchanged - memset(dest_ref, 0, PTR_ALIGN_CHK_B); // Make reference zero buff - offset = udest_ptr - dest; - - if (memcmp(dest, dest_ref, offset)) { - printf("Fail rand ualign pad start\n"); - return -1; - } - if (memcmp(dest + offset + size, dest_ref, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad end\n"); - return -1; - } - - putchar('.'); - } - - // Test all size alignment - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - - for (size = TEST_LEN; size >= TEST_MIN_SIZE; size -= align) { - srcs = TEST_SOURCES; - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) - g[i] = rand(); - - for (i = 0; i < srcs; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], buffs, dest_ref); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest); - - if (memcmp(dest_ref, dest, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } - } - - printf("done all: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-test.c b/pkg/storage/erasure/isal/src/gf-vect-dot-prod-test.c deleted file mode 100644 index f03c10eb2..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-dot-prod-test.c +++ /dev/null @@ -1,525 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset, memcmp -#include "erasure-code.h" -#include "erasure/types.h" - -#ifndef FUNCTION_UNDER_TEST -# define FUNCTION_UNDER_TEST gf_vect_dot_prod -#endif -#ifndef TEST_MIN_SIZE -# define TEST_MIN_SIZE 32 -#endif - -#define str(s) #s -#define xstr(s) str(s) - -#define TEST_LEN 8192 -#define TEST_SIZE (TEST_LEN/2) - -#ifndef TEST_SOURCES -# define TEST_SOURCES 16 -#endif -#ifndef RANDOMS -# define RANDOMS 20 -#endif - -#define MMAX TEST_SOURCES -#define KMAX TEST_SOURCES - -#ifdef EC_ALIGNED_ADDR -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 0 -# define LEN_ALIGN_CHK_B 0 // 0 for aligned only -#else -// Define power of 2 range to check ptr, len alignment -# define PTR_ALIGN_CHK_B 32 -# define LEN_ALIGN_CHK_B 32 // 0 for aligned only -#endif - -typedef unsigned char u8; - -void dump(unsigned char *buf, int len) -{ - int i; - for (i = 0; i < len;) { - printf(" %2x", 0xff & buf[i++]); - if (i % 32 == 0) - printf("\n"); - } - printf("\n"); -} - -void dump_matrix(unsigned char **s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", s[i][j]); - } - printf("\n"); - } - printf("\n"); -} - -void dump_u8xu8(unsigned char *s, int k, int m) -{ - int i, j; - for (i = 0; i < k; i++) { - for (j = 0; j < m; j++) { - printf(" %2x", 0xff & s[j + (i * m)]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - int i, j, rtest, srcs, m, k, nerrs, r, err; - void *buf; - u8 g[TEST_SOURCES], g_tbls[TEST_SOURCES * 32], src_in_err[TEST_SOURCES]; - u8 *dest, *dest_ref, *temp_buff, *buffs[TEST_SOURCES]; - u8 a[MMAX * KMAX], b[MMAX * KMAX], d[MMAX * KMAX]; - u8 src_err_list[TEST_SOURCES], *recov[TEST_SOURCES]; - - int align, size; - unsigned char *efence_buffs[TEST_SOURCES]; - unsigned int offset; - u8 *ubuffs[TEST_SOURCES]; - u8 *udest_ptr; - - printf(xstr(FUNCTION_UNDER_TEST) ": %dx%d ", TEST_SOURCES, TEST_LEN); - - // Allocate the arrays - for (i = 0; i < TEST_SOURCES; i++) { - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - buffs[i] = buf; - } - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - dest_ref = buf; - - if (posix_memalign(&buf, 64, TEST_LEN)) { - printf("alloc error: Fail"); - return -1; - } - temp_buff = buf; - - // Test of all zeros - for (i = 0; i < TEST_SOURCES; i++) - memset(buffs[i], 0, TEST_LEN); - - memset(dest, 0, TEST_LEN); - memset(temp_buff, 0, TEST_LEN); - memset(dest_ref, 0, TEST_LEN); - memset(g, 0, TEST_SOURCES); - - for (i = 0; i < TEST_SOURCES; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " \n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } else - putchar('.'); - - // Rand data test - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) - g[i] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); - FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, g_tbls, buffs, dest); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " 1\n"); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } - - putchar('.'); - } - - // Rand data test with varied parameters - for (rtest = 0; rtest < RANDOMS; rtest++) { - for (srcs = TEST_SOURCES; srcs > 0; srcs--) { - for (i = 0; i < srcs; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) - g[i] = rand(); - - for (i = 0; i < srcs; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[0], buffs, dest_ref); - FUNCTION_UNDER_TEST(TEST_LEN, srcs, g_tbls, buffs, dest); - - if (0 != memcmp(dest_ref, dest, TEST_LEN)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test 2\n"); - dump_matrix(buffs, 5, srcs); - printf("dprod_base:"); - dump(dest_ref, 5); - printf("dprod:"); - dump(dest, 5); - return -1; - } - - putchar('.'); - } - } - - // Test erasure code using gf_vect_dot_prod - - // Pick a first test - m = 9; - k = 5; - if (m > MMAX || k > KMAX) - return -1; - - gf_gen_rs_matrix(a, m, k); - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Make parity vects - for (i = k; i < m; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(a[k * i + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, buffs, buffs[i]); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], buffs, buffs[i]); -#endif - } - - // Random buffers in erasure - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0, nerrs = 0; i < k && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) - src_err_list[nerrs++] = i; - } - - // construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix((u8 *) b, (u8 *) d, k) < 0) - printf("BAD MATRIX\n"); - - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - recov[i] = buffs[r]; - } - - // Recover data - for (i = 0; i < nerrs; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(d[k * src_err_list[i] + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, recov, temp_buff); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], recov, temp_buff); -#endif - - if (0 != memcmp(temp_buff, buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d)\n", m, k, nerrs); - printf("recov %d:", src_err_list[i]); - dump(temp_buff, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - return -1; - } - } - - // Do more random tests - - for (rtest = 0; rtest < RANDOMS; rtest++) { - while ((m = (rand() % MMAX)) < 2) ; - while ((k = (rand() % KMAX)) >= m || k < 1) ; - - if (m > MMAX || k > KMAX) - continue; - - gf_gen_rs_matrix(a, m, k); - - // Make random data - for (i = 0; i < k; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - // Make parity vects - for (i = k; i < m; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(a[k * i + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, buffs, buffs[i]); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], buffs, buffs[i]); -#endif - } - - // Random errors - memset(src_in_err, 0, TEST_SOURCES); - for (i = 0, nerrs = 0; i < k && nerrs < m - k; i++) { - err = 1 & rand(); - src_in_err[i] = err; - if (err) - src_err_list[nerrs++] = i; - } - if (nerrs == 0) { // should have at least one error - while ((err = (rand() % KMAX)) >= k) ; - src_err_list[nerrs++] = err; - src_in_err[err] = 1; - } - // construct b by removing error rows - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - for (j = 0; j < k; j++) - b[k * i + j] = a[k * r + j]; - } - - if (gf_invert_matrix((u8 *) b, (u8 *) d, k) < 0) - printf("BAD MATRIX\n"); - - for (i = 0, r = 0; i < k; i++, r++) { - while (src_in_err[r]) { - r++; - continue; - } - recov[i] = buffs[r]; - } - - // Recover data - for (i = 0; i < nerrs; i++) { - for (j = 0; j < k; j++) - gf_vect_mul_init(d[k * src_err_list[i] + j], &g_tbls[j * 32]); -#ifndef USEREF - FUNCTION_UNDER_TEST(TEST_LEN, k, g_tbls, recov, temp_buff); -#else - gf_vect_dot_prod_base(TEST_LEN, k, &g_tbls[0], recov, temp_buff); -#endif - if (0 != memcmp(temp_buff, buffs[src_err_list[i]], TEST_LEN)) { - printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); - printf(" - erase list = "); - for (i = 0; i < nerrs; i++) - printf(" %d", src_err_list[i]); - printf("\na:\n"); - dump_u8xu8((u8 *) a, m, k); - printf("inv b:\n"); - dump_u8xu8((u8 *) d, k, k); - printf("orig data:\n"); - dump_matrix(buffs, m, 25); - printf("orig :"); - dump(buffs[src_err_list[i]], 25); - printf("recov %d:", src_err_list[i]); - dump(temp_buff, 25); - return -1; - } - } - putchar('.'); - } - - // Run tests at end of buffer for Electric Fence - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - for (size = TEST_MIN_SIZE; size <= TEST_SIZE; size += align) { - for (i = 0; i < TEST_SOURCES; i++) - for (j = 0; j < TEST_LEN; j++) - buffs[i][j] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) // Line up TEST_SIZE from end - efence_buffs[i] = buffs[i] + TEST_LEN - size; - - for (i = 0; i < TEST_SOURCES; i++) - g[i] = rand(); - - for (i = 0; i < TEST_SOURCES; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[0], efence_buffs, dest_ref); - FUNCTION_UNDER_TEST(size, TEST_SOURCES, g_tbls, efence_buffs, dest); - - if (0 != memcmp(dest_ref, dest, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test 3\n"); - dump_matrix(efence_buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, align); - printf("dprod:"); - dump(dest, align); - return -1; - } - - putchar('.'); - } - - // Test rand ptr alignment if available - - for (rtest = 0; rtest < RANDOMS; rtest++) { - size = (TEST_LEN - PTR_ALIGN_CHK_B) & ~(TEST_MIN_SIZE - 1); - srcs = rand() % TEST_SOURCES; - if (srcs == 0) - continue; - - offset = (PTR_ALIGN_CHK_B != 0) ? 1 : PTR_ALIGN_CHK_B; - // Add random offsets - for (i = 0; i < srcs; i++) - ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); - - udest_ptr = dest + (rand() & (PTR_ALIGN_CHK_B - offset)); - - memset(dest, 0, TEST_LEN); // zero pad to check write-over - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - ubuffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) - g[i] = rand(); - - for (i = 0; i < srcs; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], ubuffs, dest_ref); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptr); - - if (memcmp(dest_ref, udest_ptr, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign srcs=%d\n", - srcs); - dump_matrix(ubuffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(udest_ptr, 25); - return -1; - } - // Confirm that padding around dests is unchanged - memset(dest_ref, 0, PTR_ALIGN_CHK_B); // Make reference zero buff - offset = udest_ptr - dest; - - if (memcmp(dest, dest_ref, offset)) { - printf("Fail rand ualign pad start\n"); - return -1; - } - if (memcmp(dest + offset + size, dest_ref, PTR_ALIGN_CHK_B - offset)) { - printf("Fail rand ualign pad end\n"); - return -1; - } - - putchar('.'); - } - - // Test all size alignment - align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - - for (size = TEST_LEN; size >= TEST_MIN_SIZE; size -= align) { - srcs = TEST_SOURCES; - - for (i = 0; i < srcs; i++) - for (j = 0; j < size; j++) - buffs[i][j] = rand(); - - for (i = 0; i < srcs; i++) - g[i] = rand(); - - for (i = 0; i < srcs; i++) - gf_vect_mul_init(g[i], &g_tbls[i * 32]); - - gf_vect_dot_prod_base(size, srcs, &g_tbls[0], buffs, dest_ref); - - FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest); - - if (memcmp(dest_ref, dest, size)) { - printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign len=%d\n", - size); - dump_matrix(buffs, 5, TEST_SOURCES); - printf("dprod_base:"); - dump(dest_ref, 25); - printf("dprod:"); - dump(dest, 25); - return -1; - } - } - - printf("done all: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-mul-avx-perf.c b/pkg/storage/erasure/isal/src/gf-vect-mul-avx-perf.c deleted file mode 100644 index 618828dcf..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-mul-avx-perf.c +++ /dev/null @@ -1,99 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset -#include "erasure-code.h" -#include "erasure/tests.h" - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_LEN 8*1024 -# define TEST_LOOPS 4000000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN GT_L3_CACHE / 2 -# define TEST_LOOPS 1000 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -#define TEST_MEM (2 * TEST_LEN) - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i; - u8 *buff1, *buff2, gf_const_tbl[64], a = 2; - struct perf start, stop; - - printf("gf_vect_mul_avx_perf:\n"); - - gf_vect_mul_init(a, gf_const_tbl); - - // Allocate large mem region - buff1 = (u8 *) malloc(TEST_LEN); - buff2 = (u8 *) malloc(TEST_LEN); - if (NULL == buff1 || NULL == buff2) { - printf("Failed to allocate %dB\n", TEST_LEN); - return 1; - } - - memset(buff1, 0, TEST_LEN); - memset(buff2, 0, TEST_LEN); - - gf_vect_mul_avx(TEST_LEN, gf_const_tbl, buff1, buff2); - - printf("Start timed tests\n"); - fflush(0); - - gf_vect_mul_avx(TEST_LEN, gf_const_tbl, buff1, buff2); - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - gf_vect_mul_init(a, gf_const_tbl); - gf_vect_mul_avx(TEST_LEN, gf_const_tbl, buff1, buff2); - } - perf_stop(&stop); - printf("gf_vect_mul_avx" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); - - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-mul-avx-test.c b/pkg/storage/erasure/isal/src/gf-vect-mul-avx-test.c deleted file mode 100644 index d16cc6183..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-mul-avx-test.c +++ /dev/null @@ -1,143 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset -#include "erasure-code.h" - -#define TEST_SIZE 8192 -#define TEST_MEM TEST_SIZE -#define TEST_LOOPS 100000 -#define TEST_TYPE_STR "" - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i; - u8 *buff1, *buff2, *buff3, gf_const_tbl[64], a = 2; - int align, size; - unsigned char *efence_buff1; - unsigned char *efence_buff2; - unsigned char *efence_buff3; - - printf("gf_vect_mul_avx:\n"); - - gf_vect_mul_init(a, gf_const_tbl); - - buff1 = (u8 *) malloc(TEST_SIZE); - buff2 = (u8 *) malloc(TEST_SIZE); - buff3 = (u8 *) malloc(TEST_SIZE); - - if (NULL == buff1 || NULL == buff2 || NULL == buff3) { - printf("buffer alloc error\n"); - return -1; - } - // Fill with rand data - for (i = 0; i < TEST_SIZE; i++) - buff1[i] = rand(); - - gf_vect_mul_avx(TEST_SIZE, gf_const_tbl, buff1, buff2); - - for (i = 0; i < TEST_SIZE; i++) - if (gf_mul(a, buff1[i]) != buff2[i]) { - printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, buff1[i], buff2[i], - gf_mul(2, buff1[i])); - return 1; - } - - gf_vect_mul_base(TEST_SIZE, gf_const_tbl, buff1, buff3); - - // Check reference function - for (i = 0; i < TEST_SIZE; i++) - if (buff2[i] != buff3[i]) { - printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", - i, a, buff1[i], buff2[i], gf_mul(a, buff1[i])); - return 1; - } - - for (i = 0; i < TEST_SIZE; i++) - buff1[i] = rand(); - - // Check each possible constant - printf("Random tests "); - for (a = 0; a != 255; a++) { - gf_vect_mul_init(a, gf_const_tbl); - gf_vect_mul_avx(TEST_SIZE, gf_const_tbl, buff1, buff2); - - for (i = 0; i < TEST_SIZE; i++) - if (gf_mul(a, buff1[i]) != buff2[i]) { - printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", - i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); - return 1; - } - putchar('.'); - } - - // Run tests at end of buffer for Electric Fence - align = 32; - a = 2; - - gf_vect_mul_init(a, gf_const_tbl); - for (size = 0; size < TEST_SIZE; size += align) { - // Line up TEST_SIZE from end - efence_buff1 = buff1 + size; - efence_buff2 = buff2 + size; - efence_buff3 = buff3 + size; - - gf_vect_mul_avx(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff2); - - for (i = 0; i < TEST_SIZE - size; i++) - if (gf_mul(a, efence_buff1[i]) != efence_buff2[i]) { - printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", - i, efence_buff1[i], efence_buff2[i], gf_mul(2, - efence_buff1 - [i])); - return 1; - } - - gf_vect_mul_base(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff3); - - // Check reference function - for (i = 0; i < TEST_SIZE - size; i++) - if (efence_buff2[i] != efence_buff3[i]) { - printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", - i, a, efence_buff2[i], efence_buff3[i], gf_mul(2, - efence_buff1 - [i])); - return 1; - } - - putchar('.'); - } - - printf(" done: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-mul-base-test.c b/pkg/storage/erasure/isal/src/gf-vect-mul-base-test.c deleted file mode 100644 index fbd49071a..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-mul-base-test.c +++ /dev/null @@ -1,129 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset -#include "erasure-code.h" - -#define TEST_SIZE 8192 -#define TEST_MEM TEST_SIZE -#define TEST_LOOPS 100000 -#define TEST_TYPE_STR "" - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i; - u8 *buff1, *buff2, *buff3, gf_const_tbl[64], a = 2; - int align, size; - unsigned char *efence_buff1; - unsigned char *efence_buff2; - - printf("gf_vect_mul_base_test:\n"); - - gf_vect_mul_init(a, gf_const_tbl); - - buff1 = (u8 *) malloc(TEST_SIZE); - buff2 = (u8 *) malloc(TEST_SIZE); - buff3 = (u8 *) malloc(TEST_SIZE); - - if (NULL == buff1 || NULL == buff2 || NULL == buff3) { - printf("buffer alloc error\n"); - return -1; - } - // Fill with rand data - for (i = 0; i < TEST_SIZE; i++) - buff1[i] = rand(); - - gf_vect_mul_base(TEST_SIZE, gf_const_tbl, buff1, buff2); - - for (i = 0; i < TEST_SIZE; i++) - if (gf_mul(a, buff1[i]) != buff2[i]) { - printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, buff1[i], buff2[i], - gf_mul(2, buff1[i])); - return 1; - } - - gf_vect_mul_base(TEST_SIZE, gf_const_tbl, buff1, buff3); - - // Check reference function - for (i = 0; i < TEST_SIZE; i++) - if (buff2[i] != buff3[i]) { - printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", - i, a, buff1[i], buff2[i], gf_mul(a, buff1[i])); - return 1; - } - - for (i = 0; i < TEST_SIZE; i++) - buff1[i] = rand(); - - // Check each possible constant - printf("Random tests "); - for (a = 0; a != 255; a++) { - gf_vect_mul_init(a, gf_const_tbl); - gf_vect_mul_base(TEST_SIZE, gf_const_tbl, buff1, buff2); - - for (i = 0; i < TEST_SIZE; i++) - if (gf_mul(a, buff1[i]) != buff2[i]) { - printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", - i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); - return 1; - } - putchar('.'); - } - - // Run tests at end of buffer for Electric Fence - align = 32; - a = 2; - - gf_vect_mul_init(a, gf_const_tbl); - for (size = 0; size < TEST_SIZE; size += align) { - // Line up TEST_SIZE from end - efence_buff1 = buff1 + size; - efence_buff2 = buff2 + size; - - gf_vect_mul_base(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff2); - - for (i = 0; i < TEST_SIZE - size; i++) - if (gf_mul(a, efence_buff1[i]) != efence_buff2[i]) { - printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", - i, efence_buff1[i], efence_buff2[i], gf_mul(2, - efence_buff1 - [i])); - return 1; - } - - putchar('.'); - } - - printf(" done: Pass\n"); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-mul-perf.c b/pkg/storage/erasure/isal/src/gf-vect-mul-perf.c deleted file mode 100644 index 6ca1dd0cd..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-mul-perf.c +++ /dev/null @@ -1,99 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset -#include "erasure-code.h" -#include "erasure/tests.h" - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_LEN 8*1024 -# define TEST_LOOPS 4000000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN GT_L3_CACHE / 2 -# define TEST_LOOPS 1000 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -#define TEST_MEM (2 * TEST_LEN) - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i; - u8 *buff1, *buff2, gf_const_tbl[64], a = 2; - struct perf start, stop; - - printf("gf_vect_mul_perf:\n"); - - gf_vect_mul_init(a, gf_const_tbl); - - // Allocate large mem region - buff1 = (u8 *) malloc(TEST_LEN); - buff2 = (u8 *) malloc(TEST_LEN); - if (NULL == buff1 || NULL == buff2) { - printf("Failed to allocate %dB\n", TEST_LEN); - return 1; - } - - memset(buff1, 0, TEST_LEN); - memset(buff2, 0, TEST_LEN); - - gf_vect_mul(TEST_LEN, gf_const_tbl, buff1, buff2); - - printf("Start timed tests\n"); - fflush(0); - - gf_vect_mul(TEST_LEN, gf_const_tbl, buff1, buff2); - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - gf_vect_mul_init(a, gf_const_tbl); - gf_vect_mul(TEST_LEN, gf_const_tbl, buff1, buff2); - } - perf_stop(&stop); - printf("gf_vect_mul" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); - - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-mul-sse-perf.c b/pkg/storage/erasure/isal/src/gf-vect-mul-sse-perf.c deleted file mode 100644 index 374add78e..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-mul-sse-perf.c +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset -#include "erasure-code.h" -#include "erasure/tests.h" - -//#define CACHED_TEST -#ifdef CACHED_TEST -// Cached test, loop many times over small dataset -# define TEST_LEN 8*1024 -# define TEST_LOOPS 4000000 -# define TEST_TYPE_STR "_warm" -#else -# ifndef TEST_CUSTOM -// Uncached test. Pull from large mem base. -# define TEST_SOURCES 10 -# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ -# define TEST_LEN GT_L3_CACHE / 2 -# define TEST_LOOPS 1000 -# define TEST_TYPE_STR "_cold" -# else -# define TEST_TYPE_STR "_cus" -# ifndef TEST_LOOPS -# define TEST_LOOPS 1000 -# endif -# endif -#endif - -#define TEST_MEM (2 * TEST_LEN) - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i; - u8 *buff1, *buff2, gf_const_tbl[64], a = 2; - struct perf start, stop; - - printf("gf_vect_mul_sse_perf:\n"); - - gf_vect_mul_init(a, gf_const_tbl); - - // Allocate large mem region - buff1 = (u8 *) malloc(TEST_LEN); - buff2 = (u8 *) malloc(TEST_LEN); - if (NULL == buff1 || NULL == buff2) { - printf("Failed to allocate %dB\n", TEST_LEN); - return 1; - } - - memset(buff1, 0, TEST_LEN); - memset(buff2, 0, TEST_LEN); - - printf("Start timed tests\n"); - fflush(0); - - gf_vect_mul_sse(TEST_LEN, gf_const_tbl, buff1, buff2); - perf_start(&start); - for (i = 0; i < TEST_LOOPS; i++) { - gf_vect_mul_init(a, gf_const_tbl); // in a re-build would only calc once - gf_vect_mul_sse(TEST_LEN, gf_const_tbl, buff1, buff2); - } - perf_stop(&stop); - printf("gf_vect_mul_sse" TEST_TYPE_STR ": "); - perf_print(stop, start, (long long)TEST_LEN * i); - - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-mul-sse-test.c b/pkg/storage/erasure/isal/src/gf-vect-mul-sse-test.c deleted file mode 100644 index 9c90f7829..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-mul-sse-test.c +++ /dev/null @@ -1,160 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include "erasure-code.h" - -#define TEST_SIZE (128*1024) - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i; - u8 *buff1, *buff2, *buff3, gf_const_tbl[64], a = 2; - int tsize; - int align, size; - unsigned char *efence_buff1; - unsigned char *efence_buff2; - unsigned char *efence_buff3; - - printf("gf_vect_mul_sse_test: "); - - gf_vect_mul_init(a, gf_const_tbl); - - buff1 = (u8 *) malloc(TEST_SIZE); - buff2 = (u8 *) malloc(TEST_SIZE); - buff3 = (u8 *) malloc(TEST_SIZE); - - if (NULL == buff1 || NULL == buff2 || NULL == buff3) { - printf("buffer alloc error\n"); - return -1; - } - // Fill with rand data - for (i = 0; i < TEST_SIZE; i++) - buff1[i] = rand(); - - gf_vect_mul_sse(TEST_SIZE, gf_const_tbl, buff1, buff2); - - for (i = 0; i < TEST_SIZE; i++) { - if (gf_mul(a, buff1[i]) != buff2[i]) { - printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, - buff1[i], buff2[i], gf_mul(2, buff1[i])); - return -1; - } - } - - gf_vect_mul_base(TEST_SIZE, gf_const_tbl, buff1, buff3); - - // Check reference function - for (i = 0; i < TEST_SIZE; i++) { - if (buff2[i] != buff3[i]) { - printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", - i, a, buff1[i], buff2[i], gf_mul(a, buff1[i])); - return -1; - } - } - - for (i = 0; i < TEST_SIZE; i++) - buff1[i] = rand(); - - // Check each possible constant - for (a = 0; a != 255; a++) { - gf_vect_mul_init(a, gf_const_tbl); - gf_vect_mul_sse(TEST_SIZE, gf_const_tbl, buff1, buff2); - - for (i = 0; i < TEST_SIZE; i++) - if (gf_mul(a, buff1[i]) != buff2[i]) { - printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", - i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); - return -1; - } - putchar('.'); - } - - // Check buffer len - for (tsize = TEST_SIZE; tsize > 0; tsize -= 32) { - a = rand(); - gf_vect_mul_init(a, gf_const_tbl); - gf_vect_mul_sse(tsize, gf_const_tbl, buff1, buff2); - - for (i = 0; i < tsize; i++) - if (gf_mul(a, buff1[i]) != buff2[i]) { - printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", - i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); - return -1; - } - if (0 == tsize % (32 * 8)) { - putchar('.'); - fflush(0); - } - } - - // Run tests at end of buffer for Electric Fence - align = 32; - a = 2; - - gf_vect_mul_init(a, gf_const_tbl); - for (size = 0; size < TEST_SIZE; size += align) { - // Line up TEST_SIZE from end - efence_buff1 = buff1 + size; - efence_buff2 = buff2 + size; - efence_buff3 = buff3 + size; - - gf_vect_mul_sse(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff2); - - for (i = 0; i < TEST_SIZE - size; i++) - if (gf_mul(a, efence_buff1[i]) != efence_buff2[i]) { - printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", - i, efence_buff1[i], efence_buff2[i], gf_mul(2, - efence_buff1 - [i])); - return 1; - } - - gf_vect_mul_base(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff3); - - // Check reference function - for (i = 0; i < TEST_SIZE - size; i++) - if (efence_buff2[i] != efence_buff3[i]) { - printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", - i, a, efence_buff2[i], efence_buff3[i], gf_mul(2, - efence_buff1 - [i])); - return 1; - } - - putchar('.'); - } - - printf(" done: Pass\n"); - fflush(0); - return 0; -} diff --git a/pkg/storage/erasure/isal/src/gf-vect-mul-test.c b/pkg/storage/erasure/isal/src/gf-vect-mul-test.c deleted file mode 100644 index ad74f79ce..000000000 --- a/pkg/storage/erasure/isal/src/gf-vect-mul-test.c +++ /dev/null @@ -1,142 +0,0 @@ -/********************************************************************** - Copyright(c) 2011-2014 Intel Corporation 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 Intel Corporation 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 -#include -#include // for memset -#include "erasure-code.h" - -#define TEST_SIZE 8192 -#define TEST_MEM TEST_SIZE -#define TEST_LOOPS 100000 -#define TEST_TYPE_STR "" - -typedef unsigned char u8; - -int main(int argc, char *argv[]) -{ - int i; - u8 *buff1, *buff2, *buff3, gf_const_tbl[64], a = 2; - int align, size; - unsigned char *efence_buff1; - unsigned char *efence_buff2; - unsigned char *efence_buff3; - - printf("gf_vect_mul_test:\n"); - - gf_vect_mul_init(a, gf_const_tbl); - - buff1 = (u8 *) malloc(TEST_SIZE); - buff2 = (u8 *) malloc(TEST_SIZE); - buff3 = (u8 *) malloc(TEST_SIZE); - - if (NULL == buff1 || NULL == buff2 || NULL == buff3) { - printf("buffer alloc error\n"); - return -1; - } - // Fill with rand data - for (i = 0; i < TEST_SIZE; i++) - buff1[i] = rand(); - - gf_vect_mul(TEST_SIZE, gf_const_tbl, buff1, buff2); - - for (i = 0; i < TEST_SIZE; i++) - if (gf_mul(a, buff1[i]) != buff2[i]) { - printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, buff1[i], buff2[i], - gf_mul(2, buff1[i])); - return 1; - } - - gf_vect_mul_base(TEST_SIZE, gf_const_tbl, buff1, buff3); - - // Check reference function - for (i = 0; i < TEST_SIZE; i++) - if (buff2[i] != buff3[i]) { - printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", - i, a, buff1[i], buff2[i], gf_mul(a, buff1[i])); - return 1; - } - - for (i = 0; i < TEST_SIZE; i++) - buff1[i] = rand(); - - // Check each possible constant - printf("Random tests "); - for (a = 0; a != 255; a++) { - gf_vect_mul_init(a, gf_const_tbl); - gf_vect_mul(TEST_SIZE, gf_const_tbl, buff1, buff2); - - for (i = 0; i < TEST_SIZE; i++) { - if (gf_mul(a, buff1[i]) != buff2[i]) { - printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", - i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); - return 1; - } - } - putchar('.'); - } - - // Run tests at end of buffer for Electric Fence - align = 32; - a = 2; - - gf_vect_mul_init(a, gf_const_tbl); - for (size = 0; size < TEST_SIZE; size += align) { - // Line up TEST_SIZE from end - efence_buff1 = buff1 + size; - efence_buff2 = buff2 + size; - efence_buff3 = buff3 + size; - - gf_vect_mul(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff2); - - for (i = 0; i < TEST_SIZE - size; i++) - if (gf_mul(a, efence_buff1[i]) != efence_buff2[i]) { - printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", - i, efence_buff1[i], efence_buff2[i], - gf_mul(2, efence_buff1[i])); - return 1; - } - - gf_vect_mul_base(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff3); - - // Check reference function - for (i = 0; i < TEST_SIZE - size; i++) - if (efence_buff2[i] != efence_buff3[i]) { - printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", - i, a, efence_buff2[i], efence_buff3[i], - gf_mul(2, efence_buff1[i])); - return 1; - } - - putchar('.'); - } - - printf(" done: Pass\n"); - return 0; -}