diff options
author | 2016-12-15 15:04:48 -0800 | |
---|---|---|
committer | 2016-12-15 15:25:57 -0800 | |
commit | 6e2a233cae68adad9da01a233661517ef2acfebb (patch) | |
tree | ee4fc4def785a565e978f2242323b1b9ced5bd7e /tensorflow/core/platform/posix | |
parent | 1e6f5b6d269716116a1ce3239d0cd8a6c56b4d74 (diff) |
Test for CPU features on startup, to replace SIGILLs with useful errors and suggest optimizations
Change: 142193596
Diffstat (limited to 'tensorflow/core/platform/posix')
-rw-r--r-- | tensorflow/core/platform/posix/port.cc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tensorflow/core/platform/posix/port.cc b/tensorflow/core/platform/posix/port.cc index a7c797ebf2..84bc9492b5 100644 --- a/tensorflow/core/platform/posix/port.cc +++ b/tensorflow/core/platform/posix/port.cc @@ -13,6 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +#include "tensorflow/core/platform/cpu_info.h" +#include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/types.h" #if defined(__linux__) && !defined(__ANDROID__) #include <sched.h> @@ -31,7 +33,7 @@ limitations under the License. namespace tensorflow { namespace port { -void InitMain(const char* usage, int* argc, char*** argv) {} +void InitMain(const char *usage, int *argc, char ***argv) {} string Hostname() { char hostname[1024]; @@ -58,15 +60,15 @@ int NumSchedulableCPUs() { return kDefaultCores; } -void* aligned_malloc(size_t size, int minimum_alignment) { +void *aligned_malloc(size_t size, int minimum_alignment) { #if defined(__ANDROID__) return memalign(minimum_alignment, size); #else // !defined(__ANDROID__) - void* ptr = NULL; + void *ptr = NULL; // posix_memalign requires that the requested alignment be at least // sizeof(void*). In this case, fall back on malloc which should return // memory aligned to at least the size of a pointer. - const int required_alignment = sizeof(void*); + const int required_alignment = sizeof(void *); if (minimum_alignment < required_alignment) return malloc(size); if (posix_memalign(&ptr, minimum_alignment, size) != 0) return NULL; @@ -75,19 +77,19 @@ void* aligned_malloc(size_t size, int minimum_alignment) { #endif } -void aligned_free(void* aligned_memory) { free(aligned_memory); } +void aligned_free(void *aligned_memory) { free(aligned_memory); } void MallocExtension_ReleaseToSystem(std::size_t num_bytes) { // No-op. } -std::size_t MallocExtension_GetAllocatedSize(const void* p) { return 0; } +std::size_t MallocExtension_GetAllocatedSize(const void *p) { return 0; } -void AdjustFilenameForLogging(string* filename) { +void AdjustFilenameForLogging(string *filename) { // Nothing to do } -bool Snappy_Compress(const char* input, size_t length, string* output) { +bool Snappy_Compress(const char *input, size_t length, string *output) { #ifdef SNAPPY output->resize(snappy::MaxCompressedLength(length)); size_t outlen; @@ -99,8 +101,8 @@ bool Snappy_Compress(const char* input, size_t length, string* output) { #endif } -bool Snappy_GetUncompressedLength(const char* input, size_t length, - size_t* result) { +bool Snappy_GetUncompressedLength(const char *input, size_t length, + size_t *result) { #ifdef SNAPPY return snappy::GetUncompressedLength(input, length, result); #else @@ -108,7 +110,7 @@ bool Snappy_GetUncompressedLength(const char* input, size_t length, #endif } -bool Snappy_Uncompress(const char* input, size_t length, char* output) { +bool Snappy_Uncompress(const char *input, size_t length, char *output) { #ifdef SNAPPY return snappy::RawUncompress(input, length, output); #else @@ -116,7 +118,7 @@ bool Snappy_Uncompress(const char* input, size_t length, char* output) { #endif } -string Demangle(const char* mangled) { return mangled; } +string Demangle(const char *mangled) { return mangled; } } // namespace port } // namespace tensorflow |