Skip to content

Commit

Permalink
Fixed a bug in determining default integer size.
Browse files Browse the repository at this point in the history
Details:
- Fixed a bug that would cause configurations to inadvertantly define
  their integers to be 32 bits when those environments actually call for
  64-bit integers. While either BLIS_ARCH_64 or BLIS_ARCH_32 is defined
  in bli_system.h (based on whether preprocessor macros such as __x86_64
  or __aarch64__ are defined by the environment), bli_system.h was being
  #included *after* bli_config_macro_defs.h, in which the BLIS_ARCH_64
  macro was used to choose an integer type size in the event that
  BLIS_INT_TYPE_SIZE was not already defined by configure via
  bli_config.h. And due to the structure of the cpp code in that file,
  the 32-bit integer case was being chosen. Thanks to Francisco Igual
  and Devangi Parikh for their help in isolating this bug.
- Moved the #include of hbwmalloc.h and related preprocessor code to
  bli_kernel_macro_defs.h to facilitate the reshuffling of the #include
  for bli_system.h in blis.h.
  • Loading branch information
fgvanzee committed May 16, 2018
1 parent f930cec commit 12dfa95
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
10 changes: 10 additions & 0 deletions frame/include/bli_kernel_macro_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@

// -- Memory allocation --------------------------------------------------------

// hbwmalloc.h provides hbw_malloc() and hbw_free() on systems with
// libmemkind. But disable use of libmemkind if BLIS_DISABLE_MEMKIND
// was explicitly defined.
#ifdef BLIS_DISABLE_MEMKIND
#undef BLIS_ENABLE_MEMKIND
#endif
#ifdef BLIS_ENABLE_MEMKIND
#include <hbwmalloc.h>
#endif

// Memory allocation functions. These macros define the three types of
// malloc()-style functions, and their free() counterparts: one for each
// type of memory to be allocated.
Expand Down
14 changes: 2 additions & 12 deletions frame/include/bli_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
#include <float.h>
#include <errno.h>

// Determine if we are on a 64-bit or 32-bit architecture
// Determine if we are on a 64-bit or 32-bit architecture.
#if defined(_M_X64) || defined(__x86_64) || defined(__aarch64__) || \
defined(_ARCH_PPC64)
#define BLIS_ARCH_64
#else
#define BLIS_ARCH_32
#endif

// Determine the target operating system
// Determine the target operating system.
#if defined(_WIN32) || defined(__CYGWIN__)
#define BLIS_OS_WINDOWS 1
#elif defined(__APPLE__) || defined(__MACH__)
Expand Down Expand Up @@ -99,15 +99,5 @@
#include <time.h>
#endif

// hbwmalloc.h provides hbw_malloc() and hbw_free() on systems with
// libmemkind. But disable use of libmemkind if BLIS_DISABLE_MEMKIND
// was explicitly defined.
#ifdef BLIS_DISABLE_MEMKIND
#undef BLIS_ENABLE_MEMKIND
#endif
#ifdef BLIS_ENABLE_MEMKIND
#include <hbwmalloc.h>
#endif


#endif
20 changes: 8 additions & 12 deletions frame/include/blis.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,19 @@
extern "C" {
#endif

// NOTE: PLEASE DON'T CHANGE THE ORDER IN WHICH HEADERS ARE INCLUDED UNLESS
// YOU ARE SURE THAT IT DOESN'T BREAK INTER-HEADER MACRO DEPENDENCIES.

// -- BLIS configuration definition --
// -- System headers --
// NOTE: This header must be included before bli_config_macro_defs.h.

// NOTE: We include bli_config.h first because there might be something
// defined there that is needed within one of the system headers. A good
// example: posix_memalign() needs _GNU_SOURCE on GNU systems (I think).
//
// PLEASE DON'T CHANGE THE ORDER IN WHICH HEADERS ARE INCLUDED UNLESS YOU
// KNOW WHAT YOU ARE DOING.
#include "bli_system.h"

#include "bli_config.h"
#include "bli_config_macro_defs.h"

// -- configure definitions --

// -- System headers --

#include "bli_system.h"
#include "bli_config.h"
#include "bli_config_macro_defs.h"


// -- Common BLIS definitions --
Expand Down

0 comments on commit 12dfa95

Please sign in to comment.