Skip to content

Commit

Permalink
Merge pull request #51 from szhorvat/lbfgs-update
Browse files Browse the repository at this point in the history
  • Loading branch information
ntamas authored Nov 20, 2024
2 parents c98d8be + 9151d55 commit ffa9ea7
Show file tree
Hide file tree
Showing 17 changed files with 306 additions and 87 deletions.
39 changes: 34 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Build and run tests

on: [push, pull_request]

env:
CMAKE_COLOR_DIAGNOSTICS: ON
OMP_NUM_THREADS: 1

jobs:
build:
name: ${{ matrix.config.name }}
Expand All @@ -12,21 +16,45 @@ jobs:
matrix:
config:
- {
name: "Windows",
name: "Windows static",
os: windows-latest,
build_type: "Release",
shared_libs: false,
generators: "Visual Studio 17 2022"
}
- {
name: "Ubuntu Linux static",
os: ubuntu-latest,
build_type: "Release",
shared_libs: false,
generators: "Ninja"
}
- {
name: "macOS static",
os: macos-latest,
build_type: "Release",
shared_libs: false,
generators: "Ninja"
}
- {
name: "Windows shared",
os: windows-latest,
build_type: "Release",
shared_libs: true,
generators: "Visual Studio 17 2022"
}
- {
name: "Ubuntu Linux",
name: "Ubuntu Linux shared",
os: ubuntu-latest,
build_type: "Release",
shared_libs: true,
generators: "Ninja"
}
- {
name: "macOS",
name: "macOS shared",
os: macos-latest,
build_type: "Release",
shared_libs: true,
generators: "Ninja"
}

Expand Down Expand Up @@ -56,6 +84,7 @@ jobs:
cmake \
-S . \
-B build \
-DBUILD_SHARED_LIBS=${{ matrix.config.shared_libs }} \
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
-G "${{ matrix.config.generators }}" \
-DCMAKE_INSTALL_PREFIX:PATH=instdir
Expand All @@ -70,13 +99,13 @@ jobs:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
cd build
ctest --output-junit report.xml
ctest -C ${{ matrix.config.build_type }} --output-junit report.xml
- name: Archive unit test results
uses: actions/upload-artifact@v4
if: always()
with:
name: unit-test-results-${{ matrix.config.os }}
name: unit-test-results-${{ matrix.config.os }}-${{ matrix.config.shared_libs }}
path: build/report.xml

- name: Install and strip
Expand Down
4 changes: 2 additions & 2 deletions src/arithmetic_ansi.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* THE SOFTWARE.
*/

/* $Id: arithmetic_ansi.h 65 2010-01-29 12:19:16Z naoaki $ */
/* $Id$ */

#include <stdlib.h>
#include <memory.h>
Expand Down Expand Up @@ -51,7 +51,7 @@ inline static void vecfree(void *memblock)
inline static void vecset(lbfgsfloatval_t *x, const lbfgsfloatval_t c, const int n)
{
int i;

for (i = 0;i < n;++i) {
x[i] = c;
}
Expand Down
22 changes: 11 additions & 11 deletions src/arithmetic_sse_double.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
* THE SOFTWARE.
*/

/* $Id: arithmetic_sse_double.h 65 2010-01-29 12:19:16Z naoaki $ */
/* $Id$ */

#include <stdlib.h>

#if !defined(__APPLE__)
#ifndef __APPLE__
#include <malloc.h>
#endif

#include <memory.h>

#if 1400 <= _MSC_VER
Expand All @@ -43,13 +41,15 @@

inline static void* vecalloc(size_t size)
{
#ifdef _WIN32
#if defined(_WIN32)
void *memblock = _aligned_malloc(size, 16);
#elif defined(__APPLE__)
/* Memory on Mac OS X is already aligned to 16 bytes */
void *memblock = malloc(size);
#elif defined(__APPLE__) /* OS X always aligns on 16-byte boundaries */
void *memblock = malloc(size);
#else
void *memblock = memalign(16, size);
void *memblock = NULL, *p = NULL;
if (posix_memalign(&p, 16, size) == 0) {
memblock = p;
}
#endif
if (memblock != NULL) {
memset(memblock, 0, size);
Expand All @@ -59,7 +59,7 @@ inline static void* vecalloc(size_t size)

inline static void vecfree(void *memblock)
{
#ifdef _WIN32
#ifdef _MSC_VER
_aligned_free(memblock);
#else
free(memblock);
Expand Down Expand Up @@ -199,7 +199,7 @@ inline static void vecfree(void *memblock)



#if 3 <= __SSE__
#if 3 <= __SSE__ || defined(__SSE3__)
/*
Horizontal add with haddps SSE3 instruction. The work register (rw)
is unused.
Expand Down
21 changes: 16 additions & 5 deletions src/arithmetic_sse_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
* THE SOFTWARE.
*/

/* $Id: arithmetic_sse_float.h 65 2010-01-29 12:19:16Z naoaki $ */
/* $Id$ */

#include <stdlib.h>

#if !defined(__APPLE__)
#ifndef __APPLE__
#include <malloc.h>
#endif

#include <memory.h>

#if 1400 <= _MSC_VER
Expand All @@ -49,7 +47,16 @@

inline static void* vecalloc(size_t size)
{
#if defined(_MSC_VER)
void *memblock = _aligned_malloc(size, 16);
#elif defined(__APPLE__) /* OS X always aligns on 16-byte boundaries */
void *memblock = malloc(size);
#else
void *memblock = NULL, *p = NULL;
if (posix_memalign(&p, 16, size) == 0) {
memblock = p;
}
#endif
if (memblock != NULL) {
memset(memblock, 0, size);
}
Expand All @@ -58,7 +65,11 @@ inline static void* vecalloc(size_t size)

inline static void vecfree(void *memblock)
{
#ifdef _MSC_VER
_aligned_free(memblock);
#else
free(memblock);
#endif
}

#define vecset(x, c, n) \
Expand Down Expand Up @@ -189,7 +200,7 @@ inline static void vecfree(void *memblock)



#if 3 <= __SSE__
#if 3 <= __SSE__ || defined(__SSE3__)
/*
Horizontal add with haddps SSE3 instruction. The work register (rw)
is unused.
Expand Down
Loading

0 comments on commit ffa9ea7

Please sign in to comment.