-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config variable for selection of dot product function
All also a C++ implementation with more aggressive compiler options which is optimized for the CPU where the software was built. It is now possible to select the function used for the dot product with -c dotproduct=FUNCTION where FUNCTION can be one of those values: * auto selection based on detected hardware (default) * generic C++ code with default compiler options * native C++ code optimized for build host * avx optimized code for AVX * sse optimized code for SSE Signed-off-by: Stefan Weil <sw@weilnetz.de>
- Loading branch information
Showing
9 changed files
with
160 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/////////////////////////////////////////////////////////////////////// | ||
// File: dotproduct.h | ||
// Description: Native dot product function. | ||
// | ||
// (C) Copyright 2018, Google Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/////////////////////////////////////////////////////////////////////// | ||
|
||
#include "dotproduct.h" | ||
|
||
namespace tesseract { | ||
|
||
// Computes and returns the dot product of the two n-vectors u and v. | ||
double DotProductNative(const double* u, const double* v, int n) { | ||
double total = 0.0; | ||
for (int k = 0; k < n; ++k) total += u[k] * v[k]; | ||
return total; | ||
} | ||
|
||
} // namespace tesseract |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/////////////////////////////////////////////////////////////////////// | ||
// File: dotproduct.h | ||
// Description: Native dot product function. | ||
// | ||
// (C) Copyright 2018, Google Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef TESSERACT_ARCH_DOTPRODUCT_H_ | ||
#define TESSERACT_ARCH_DOTPRODUCT_H_ | ||
|
||
namespace tesseract { | ||
|
||
// Computes and returns the dot product of the n-vectors u and v. | ||
double DotProductNative(const double* u, const double* v, int n); | ||
|
||
} // namespace tesseract. | ||
|
||
#endif // TESSERACT_ARCH_DOTPRODUCT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters