Skip to content

Commit

Permalink
[revert] reverting the commits from #578, leaving header file in repo…
Browse files Browse the repository at this point in the history
… for the moment
  • Loading branch information
albarrentine committed Jul 6, 2023
1 parent c76d020 commit 57eaa41
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 105 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ brew install curl autoconf automake libtool pkg-config

Then to install the C library:

If you're using an M1 Mac, add `--disable-sse2` to the `./configure` command. This will result in poorer performance but the build will succeed.

```
git clone https://github.com/openvenues/libpostal
cd libpostal
Expand Down
55 changes: 9 additions & 46 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -84,57 +84,20 @@ AS_IF([test "x$FOUND_SHUF" = xyes], [AC_DEFINE([HAVE_SHUF], [1], [shuf availabl
AS_IF([test "x$FOUND_GSHUF" = xyes], [AC_DEFINE([HAVE_GSHUF], [1], [gshuf available])])

# ------------------------------------------------------------------
# Architecture-specific options
# Checks for SSE2 build
# ------------------------------------------------------------------

# allow enabling hardware optimization on any system:
case "$host_cpu" in
arm*|aarch64*)
enable_arm_neon=yes
enable_intel_sse=no
AC_DEFINE([ARM_NEON], [1],
[Enable ARM_NEON optimizations])
;;
i?86|x86_64)
enable_intel_sse=yes
enable_arm_neon=no
AC_DEFINE([INTEL_SSE], [1],
[Enable Intel SSE optimizations])
;;
esac

AC_ARG_ENABLE([neon],
AS_HELP_STRING([[[--disable-neon]]],
[Disable ARM NEON hardware optimizations]),
[
enable_arm_neon=no
AC_DEFINE([ARM_NEON], [0],
[Disable ARM_NEON optimizations])
])

AC_ARG_ENABLE([sse2],
AS_HELP_STRING([[[--disable-sse2]]],
[Disable Intel SSE2 hardware optimizations]),
[
enable_intel_sse=no
AC_DEFINE([INTEL_SSE], [0],
[Disable INTEL_SSE optimizations])
])

SIMDFLAGS=""

AS_IF([test "x$enable_intel_sse" != "xno"], [
SIMDFLAGS="-mfpmath=sse -msse2 -DINTEL_SSE"
])

AS_IF([test "x$enable_arm_neon" != "xno"], [
SIMDFLAGS="-march=armv8-a+fp+simd+crypto+crc -DARM_NEON"
AS_HELP_STRING(
[--disable-sse2],
[disable SSE2 optimization routines]
)
)

AS_IF([test "x$enable_sse2" != "xno"], [
CFLAGS="-mfpmath=sse -msse2 -DUSE_SSE ${CFLAGS}"
])

CFLAGS="${SIMDFLAGS} ${CFLAGS}"

AC_SUBST([SIMDFLAGS], [$SIMDFLAGS])

AC_CHECK_HEADER(cblas.h, [AX_CBLAS])

AC_ARG_ENABLE([data-download],
Expand Down
16 changes: 8 additions & 8 deletions src/crf_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ crf_context_t *crf_context_new(int flag, size_t L, size_t T) {
}

if (context->flag & CRF_CONTEXT_MARGINALS) {
#if defined(INTEL_SSE) || defined(ARM_NEON)
#if defined(USE_SSE)
context->exp_state = double_matrix_new_aligned(T, L, 32);
if (context->exp_state == NULL) goto exit_context_created;
double_matrix_zero(context->exp_state);
Expand All @@ -52,7 +52,7 @@ crf_context_t *crf_context_new(int flag, size_t L, size_t T) {
context->mexp_state = double_matrix_new_zeros(T, L);
if (context->mexp_state == NULL) goto exit_context_created;

#if defined(INTEL_SSE) || defined(ARM_NEON)
#if defined(USE_SSE)
context->exp_state_trans = double_matrix_new_aligned(T, L * L, 32);
if (context->exp_state_trans == NULL) goto exit_context_created;
double_matrix_zero(context->exp_state_trans);
Expand All @@ -64,7 +64,7 @@ crf_context_t *crf_context_new(int flag, size_t L, size_t T) {
context->mexp_state_trans = double_matrix_new_zeros(T, L * L);
if (context->mexp_state_trans == NULL) goto exit_context_created;

#if defined(INTEL_SSE) || defined(ARM_NEON)
#if defined(USE_SSE)
context->exp_trans = double_matrix_new_aligned(L, L, 32);
if (context->exp_trans == NULL) goto exit_context_created;
double_matrix_zero(context->exp_trans);
Expand Down Expand Up @@ -130,13 +130,13 @@ bool crf_context_set_num_items(crf_context_t *self, size_t T) {

if (self->flag & CRF_CONTEXT_MARGINALS &&
(
#if defined(INTEL_SSE) || defined(ARM_NEON)
#if defined(USE_SSE)
!double_matrix_resize_aligned(self->exp_state, T, L, 32) ||
#else
!double_matrix_resize(self->exp_state, T, L) ||
#endif
!double_matrix_resize(self->mexp_state, T, L) ||
#if defined(INTEL_SSE) || defined(ARM_NEON)
#if defined(USE_SSE)
!double_matrix_resize_aligned(self->exp_state_trans, T, L * L, 32) ||
#else
!double_matrix_resize(self->exp_state_trans, T, L * L) ||
Expand Down Expand Up @@ -184,7 +184,7 @@ void crf_context_destroy(crf_context_t *self) {
}

if (self->exp_state != NULL) {
#if defined(INTEL_SSE) || defined(ARM_NEON)
#if defined(USE_SSE)
double_matrix_destroy_aligned(self->exp_state);
#else
double_matrix_destroy(self->exp_state);
Expand All @@ -200,7 +200,7 @@ void crf_context_destroy(crf_context_t *self) {
}

if (self->exp_state_trans != NULL) {
#if defined(INTEL_SSE) || defined(ARM_NEON)
#if defined(USE_SSE)
double_matrix_destroy_aligned(self->exp_state_trans);
#else
double_matrix_destroy(self->exp_state_trans);
Expand All @@ -216,7 +216,7 @@ void crf_context_destroy(crf_context_t *self) {
}

if (self->exp_trans != NULL) {
#if defined(INTEL_SSE) || defined(ARM_NEON)
#if defined(USE_SSE)
double_matrix_destroy_aligned(self->exp_trans);
#else
double_matrix_destroy(self->exp_trans);
Expand Down
6 changes: 2 additions & 4 deletions src/vector_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

#define ks_lt_index(a, b) ((a).value < (b).value)

#if defined(INTEL_SSE)
#if defined(USE_SSE)
#include <emmintrin.h>
#elif defined(ARM_NEON)
#include "sse2neon.h"
#endif

/*
Expand Down Expand Up @@ -340,7 +338,7 @@



#if defined(INTEL_SSE) || defined(ARM_NEON)
#if defined(USE_SSE)
/*
From https://github.com/herumi/fmath/blob/master/fastexp.cpp
Expand Down
2 changes: 1 addition & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CFLAGS_O2 = $(CFLAGS_BASE) -O2
CFLAGS_O3 = $(CFLAGS_BASE) -O3
DEFAULT_INCLUDES = -I.. -I/usr/local/include

CFLAGS = $(SIMDFLAGS) $(CFLAGS_BASE)
CFLAGS = $(CFLAGS_BASE)

TESTS = test_libpostal
noinst_PROGRAMS = test_libpostal
Expand Down
55 changes: 9 additions & 46 deletions windows/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -73,57 +73,20 @@ AS_IF([test "x$FOUND_SHUF" = xyes], [AC_DEFINE([HAVE_SHUF], [1], [shuf availabl
AS_IF([test "x$FOUND_GSHUF" = xyes], [AC_DEFINE([HAVE_GSHUF], [1], [gshuf available])])

# ------------------------------------------------------------------
# Architecture-specific options
# Checks for SSE2 build
# ------------------------------------------------------------------

# allow enabling hardware optimization on any system:
case "$host_cpu" in
arm*|aarch64*)
enable_arm_neon=yes
enable_intel_sse=no
AC_DEFINE([ARM_NEON], [1],
[Enable ARM_NEON optimizations])
;;
i?86|x86_64)
enable_intel_sse=yes
enable_arm_neon=no
AC_DEFINE([INTEL_SSE], [1],
[Enable Intel SSE optimizations])
;;
esac

AC_ARG_ENABLE([neon],
AS_HELP_STRING([[[--disable-neon]]],
[Disable ARM NEON hardware optimizations]),
[
enable_arm_neon=no
AC_DEFINE([ARM_NEON], [0],
[Disable ARM_NEON optimizations])
])

AC_ARG_ENABLE([sse2],
AS_HELP_STRING([[[--disable-sse2]]],
[Disable Intel SSE2 hardware optimizations]),
[
enable_intel_sse=no
AC_DEFINE([INTEL_SSE], [0],
[Disable INTEL_SSE optimizations])
])

SIMDFLAGS=""

AS_IF([test "x$enable_intel_sse" != "xno"], [
SIMDFLAGS="-mfpmath=sse -msse2 -DINTEL_SSE"
])

AS_IF([test "x$enable_arm_neon" != "xno"], [
SIMDFLAGS="-march=armv8-a+fp+simd+crypto+crc -DARM_NEON"
AS_HELP_STRING(
[--disable-sse2],
[disable SSE2 optimization routines]
)
)

AS_IF([test "x$enable_sse2" != "xno"], [
CFLAGS="-mfpmath=sse -msse2 -DUSE_SSE ${CFLAGS}"
])

CFLAGS="${SIMDFLAGS} ${CFLAGS}"

AC_SUBST([SIMDFLAGS], [$SIMDFLAGS])

AC_CHECK_HEADER(cblas.h, [AX_CBLAS])

AC_ARG_ENABLE([data-download],
Expand Down

0 comments on commit 57eaa41

Please sign in to comment.