Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Options in C and Fortran APIs #152

Merged
merged 14 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ docs/doxygen/errors.txt
docs/html/
files.txt
include/slate/c_api/matrix.h
include/slate/c_api/util.hh
include/slate/c_api/wrappers.h
issues/
lib/*.a
Expand All @@ -22,6 +21,7 @@ lib/pkgconfig/*.pc
make.inc
src/c_api/matrix.cc
src/c_api/util.cc
src/c_api/util.hh
src/c_api/wrappers_precisions.cc
src/cuda/*.md5
src/fortran/slate_module.f90
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,14 @@ if (c_api)
set( cmd ${Python_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/c_api/generate_util.py
${CMAKE_CURRENT_SOURCE_DIR}/include/slate/c_api/types.h
${CMAKE_CURRENT_SOURCE_DIR}/include/slate/c_api/util.hh
${CMAKE_CURRENT_SOURCE_DIR}/src/c_api/util.hh
${CMAKE_CURRENT_SOURCE_DIR}/src/c_api/util.cc )
execute_process( COMMAND ${cmd} )

set( cmd ${Python_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/c_api/generate_matrix.py
${CMAKE_CURRENT_SOURCE_DIR}/include/slate/Tile.hh
${CMAKE_CURRENT_SOURCE_DIR}/include/slate/types.hh
${CMAKE_CURRENT_SOURCE_DIR}/include/slate/c_api/matrix.h
${CMAKE_CURRENT_SOURCE_DIR}/src/c_api/matrix.cc )
execute_process( COMMAND ${cmd} )
Expand Down
25 changes: 12 additions & 13 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,6 @@ install: lib ${pkg}
if [ ${c_api} -eq 1 ]; then \
mkdir -p ${DESTDIR}${abs_prefix}/include/slate/c_api; \
cp include/slate/c_api/*.h ${DESTDIR}${abs_prefix}/include/slate/c_api; \
cp include/slate/c_api/*.hh ${DESTDIR}${abs_prefix}/include/slate/c_api; \
fi
if [ ${fortran_api} -eq 1 ]; then \
cp slate.mod ${DESTDIR}${abs_prefix}/include/; \
Expand Down Expand Up @@ -957,22 +956,20 @@ ifeq ($(c_api),1)
${python} tools/c_api/generate_wrappers.py $< $@ \
src/c_api/wrappers_precisions.cc

include/slate/c_api/matrix.h: include/slate/Tile.hh
${python} tools/c_api/generate_matrix.py $< $@ \
src/c_api/matrix.cc
include/slate/c_api/matrix.h: include/slate/Tile.hh include/slate/types.hh
${python} tools/c_api/generate_matrix.py $^ $@ src/c_api/matrix.cc

include/slate/c_api/util.hh: include/slate/c_api/types.h
${python} tools/c_api/generate_util.py $< $@ \
src/c_api/util.cc
src/c_api/util.hh: include/slate/c_api/types.h
${python} tools/c_api/generate_util.py $< $@ src/c_api/util.cc

src/c_api/wrappers_precisions.cc: include/slate/c_api/wrappers.h
src/c_api/matrix.cc: include/slate/c_api/matrix.h
src/c_api/util.cc: include/slate/c_api/util.hh
src/c_api/wrappers.o: include/slate/c_api/wrappers.h
src/c_api/wrappers_precisions.cc: include/slate/c_api/wrappers.h src/c_api/util.hh
src/c_api/matrix.cc: include/slate/c_api/matrix.h src/c_api/util.hh
src/c_api/util.cc: src/c_api/util.hh
src/c_api/wrappers.o: include/slate/c_api/wrappers.h src/c_api/util.hh

generate: include/slate/c_api/wrappers.h
generate: include/slate/c_api/matrix.h
generate: include/slate/c_api/util.hh
generate: src/c_api/util.hh
endif

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -1292,7 +1289,9 @@ ${pkg}:
s'#CPPFLAGS'${CPPFLAGS_clean}'; \
s'#LDFLAGS'${LDFLAGS_clean}'; \
s'#LIBS'${LIBS}'; \
s'#SCALAPACK'${SCALAPACK_LIBRARIES}';" \
s'#SCALAPACK_LIBRARIES'${SCALAPACK_LIBRARIES}'; \
s'#C_API'${c_api}'; \
s'#FORTRAN_API'${fortran_api}';" \
[email protected] > $@

#-------------------------------------------------------------------------------
Expand Down
50 changes: 43 additions & 7 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ ifneq (${pkg_exists},0)
${error pkg-config could not find slate. Install SLATE, then add /prefix/lib/pkgconfig with your prefix to $$PKG_CONFIG_PATH.}
endif

CXX = ${shell pkg-config --variable=CXX slate}
CXXFLAGS += ${shell pkg-config --cflags slate}
LDFLAGS += ${shell pkg-config --libs-only-L slate}
LDFLAGS += ${shell pkg-config --libs-only-other slate}
slate_libs = ${shell pkg-config --libs-only-l slate}
scalapack_libs = ${shell pkg-config --variable=scalapack slate}
CXX = ${shell pkg-config --variable=CXX slate}
CXXFLAGS += ${shell pkg-config --cflags slate}
LDFLAGS += ${shell pkg-config --libs-only-L slate}
LDFLAGS += ${shell pkg-config --libs-only-other slate}
slate_libs = ${shell pkg-config --libs-only-l slate}
scalapack_libs = ${shell pkg-config --variable=scalapack slate}
c_api = ${shell pkg-config --variable=c_api slate}
fortran_api = ${shell pkg-config --variable=fortran_api slate}

#-------------------------------------------------------------------------------
# SLATE's ScaLAPACK API example
Expand Down Expand Up @@ -48,12 +50,34 @@ ${slate_exe}: %: %.o
${CXX} -o $@ $^ \
${LDFLAGS} ${slate_libs} ${LIBS}

.PHONY: c_api
c_api:
cd c_api && ${MAKE} all

.PHONY: fortran
fortran:
cd fortran && ${MAKE} all


#-------------------------------------------------------------------------------
# `make test` rule

test_args ?= s d c z

test_extras :=

ifeq (${c_api},1)
test_extras += --c_api
endif

ifeq (${fortran_api},1)
test_extras += --fortran
endif

# CMake uses `make test`, GNU autotools uses `make check`; allow both.
test: check
check: ${exe}
./run_tests.py --type "${test_args}"
./run_tests.py --type "${test_args}" ${test_extras}

#-------------------------------------------------------------------------------
# Generic rules.
Expand All @@ -63,11 +87,23 @@ check: ${exe}

all: ${exe}

ifeq (${c_api},1)
all: c_api
endif

ifeq (${fortran_api},1)
all: fortran
endif

%.o: %.cc
${CXX} ${CXXFLAGS} -c -o $@ $<

clean:
${RM} ${exe} *.o *.d
@echo
cd c_api && ${MAKE} clean
@echo
cd fortran && ${MAKE} clean

clean_exe:
${RM} ${exe}
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This installs it into a sub-directory of the SLATE source.

slate> make
slate> make install prefix=install
slate> export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:`pwd`/install
slate> export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:`pwd`/install/lib/pkgconfig

Build examples:

Expand Down
68 changes: 68 additions & 0 deletions examples/c_api/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Queries pkg-config for all libraries to link with.

-include make.inc

pkg_exists := ${shell pkg-config --exists slate; echo $$?}
ifneq (${pkg_exists},0)
${error pkg-config could not find slate. Install SLATE, then add /prefix/lib/pkgconfig with your prefix to $$PKG_CONFIG_PATH.}
endif

CC = mpicc
CFLAGS += ${shell pkg-config --cflags slate}
LDFLAGS += ${shell pkg-config --libs-only-L slate}
LDFLAGS += ${shell pkg-config --libs-only-other slate}
slate_libs = ${shell pkg-config --libs-only-l slate}

mgates3 marked this conversation as resolved.
Show resolved Hide resolved
CFLAGS := ${filter-out -std=c++%, ${CFLAGS}}

#-------------------------------------------------------------------------------
# SLATE examples
# Link with -lslate -llapackpp -lblaspp.
# Implicitly links with your BLAS library.

slate_src = ${wildcard *.c}
slate_exe = ${basename ${slate_src}}
exe += ${slate_exe}

slate: ${slate_exe}
mgates3 marked this conversation as resolved.
Show resolved Hide resolved

${slate_exe}: %: %.o
${CC} -o $@ $^ \
${LDFLAGS} ${slate_libs} ${LIBS}

#-------------------------------------------------------------------------------
# Generic rules.

.SUFFIXES:
.DEFAULT_GOAL := all

all: ${exe}

%.o: %.c
${CC} ${CFLAGS} -c -o $@ $<

clean:
${RM} ${exe} *.o *.d

clean_exe:
${RM} ${exe}

distclean: clean

-include *.d

#-------------------------------------------------------------------------------
# Debugging

echo:
@echo "CC = ${CC}"
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "LIBS = ${LIBS}"
@echo "slate_libs = ${slate_libs}"
@echo
@echo "slate_src = ${slate_src}"
@echo "slate_exe = ${slate_exe}"
@echo
@echo "exe = ${exe}"

Loading
Loading