-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf2c94b
commit 56142ff
Showing
6 changed files
with
496 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
#------------------------------------------------------------------------------- | ||
# LAGraph/Test/extract/CMakeLists.txt: cmake script for LAGraph test | ||
#------------------------------------------------------------------------------- | ||
|
||
# LAGraph, (... list all authors here) (c) 2019, All Rights Reserved. | ||
# http://lagraph.org See LAGraph/LICENSE for license. | ||
|
||
# CMakeLists.txt: instructions for cmake to build LAGraph. | ||
# An ANSI C11 compiler is required. | ||
# | ||
# First, install any GraphBLAS library. | ||
# Alternatively, use ../GraphBLAS (see comments below). | ||
# | ||
# To compile and install the LAGraph library: | ||
# | ||
# make | ||
# sudo make install | ||
# | ||
# Then to compile and run the Demos: | ||
# | ||
# cd Demos | ||
# make | ||
# | ||
# If that fails for any reason, make sure your compiler supports ANSI C11. You | ||
# could try changing your compiler, for example: | ||
# | ||
# cd build | ||
# CC=icc cmake .. | ||
# cd .. | ||
# make | ||
# | ||
# Or, with other compilers: | ||
# | ||
# CC=xlc cmake .. | ||
# CC=gcc cmake .. | ||
# | ||
# To remove all compiled files and libraries (except installed ones): | ||
# | ||
# make distclean | ||
|
||
#------------------------------------------------------------------------------- | ||
# get the version | ||
#------------------------------------------------------------------------------- | ||
|
||
# cmake 3.0 is preferred. | ||
cmake_minimum_required ( VERSION 2.8.12 ) | ||
|
||
if ( CMAKE_VERSION VERSION_GREATER "3.0" ) | ||
cmake_policy ( SET CMP0042 NEW ) | ||
cmake_policy ( SET CMP0048 NEW ) | ||
endif ( ) | ||
|
||
project ( extract_test ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# determine build type | ||
#------------------------------------------------------------------------------- | ||
|
||
include ( GNUInstallDirs ) | ||
|
||
# For development only, not for end-users: | ||
# set ( CMAKE_BUILD_TYPE Debug ) | ||
|
||
if ( NOT CMAKE_BUILD_TYPE ) | ||
set ( CMAKE_BUILD_TYPE Release ) | ||
endif ( ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# edit these lines to select your GraphBLAS library | ||
#------------------------------------------------------------------------------- | ||
|
||
# link_directories ( /usr/local/lib ) | ||
link_directories ( ../../../GraphBLAS/build ) | ||
link_directories ( ../../build ) | ||
|
||
# include_directories ( /usr/local/include ) | ||
include_directories ( ../../../GraphBLAS/Include ) | ||
include_directories ( ../../Include ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# determine what user threading model to use | ||
#------------------------------------------------------------------------------- | ||
|
||
include ( FindOpenMP ) | ||
include ( FindThreads ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# report status | ||
#------------------------------------------------------------------------------- | ||
|
||
message ( STATUS "CMAKE build type: " ${CMAKE_BUILD_TYPE} ) | ||
|
||
if ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug") | ||
message ( STATUS "CMAKE C Flags debug: " ${CMAKE_C_FLAGS_DEBUG} ) | ||
else ( ) | ||
message ( STATUS "CMAKE C Flags release: " ${CMAKE_C_FLAGS_RELEASE} ) | ||
endif ( ) | ||
|
||
message ( STATUS "CMAKE compiler ID: " ${CMAKE_C_COMPILER_ID} ) | ||
message ( STATUS "CMAKE thread library: " ${CMAKE_THREAD_LIBS_INIT} ) | ||
message ( STATUS "CMAKE have pthreads: " ${CMAKE_USE_PTHREADS_INIT} ) | ||
message ( STATUS "CMAKE have Win32 pthreads: " ${CMAKE_USE_WIN32_THREADS_INIT} ) | ||
message ( STATUS "CMAKE have OpenMP: " ${OPENMP_FOUND} ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# include directories | ||
#------------------------------------------------------------------------------- | ||
|
||
set ( CMAKE_INCLUDE_CURRENT_DIR ON ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# compiler options | ||
#------------------------------------------------------------------------------- | ||
|
||
# check which compiler is being used. If you need to make | ||
# compiler-specific modifications, here is the place to do it. | ||
if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") | ||
# cmake 2.8 workaround: gcc needs to be told to do ANSI C11. | ||
# cmake 3.0 doesn't have this problem. | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -lm -Wno-pragmas " ) | ||
# check all warnings: | ||
# set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -Werror " ) | ||
if ( CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9 ) | ||
message ( FATAL_ERROR "gcc version must be at least 4.9" ) | ||
endif ( ) | ||
elseif ( "${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" ) | ||
# options for icc: also needs -std=c11 | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 " ) | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qopt-malloc-options=3" ) | ||
# check all warnings: | ||
# set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w3 " ) | ||
if ( CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0 ) | ||
message ( FATAL_ERROR "icc version must be at least 18.0" ) | ||
endif ( ) | ||
elseif ( "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" ) | ||
# options for clang | ||
if ( CMAKE_C_COMPILER_VERSION VERSION_LESS 3.3 ) | ||
message ( FATAL_ERROR "clang version must be at least 3.3" ) | ||
endif ( ) | ||
elseif ( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" ) | ||
# options for MicroSoft Visual Studio | ||
endif ( ) | ||
|
||
if ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug") | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}" ) | ||
else ( ) | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}" ) | ||
endif ( ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# select the threading library | ||
#------------------------------------------------------------------------------- | ||
|
||
if ( USER_OPENMP ) | ||
# user insists on OpenMP synchronization inside LAGraph | ||
message ( STATUS "cmake -DUSER_OPENMP=1: insisting on using OpenMP" ) | ||
set ( USE_OPENMP true ) | ||
elseif ( USER_POSIX ) | ||
# user insists on POSIX synchronization inside LAGraph | ||
message ( STATUS "cmake -DUSER_POSIX=1: insisting on using POSIX" ) | ||
set ( USE_POSIX true ) | ||
elseif ( USER_NONE ) | ||
message ( STATUS "cmake -DUSER_NONE=1: insisting on using no threading" ) | ||
set ( USE_NONE true ) | ||
else ( ) | ||
# default: automatic selection | ||
message ( STATUS "Automatic selection of synchronization method" ) | ||
if ( OPENMP_FOUND ) | ||
set ( USE_OPENMP true ) | ||
elseif ( CMAKE_USE_PTHREADS_INIT ) | ||
set ( USE_POSIX true ) | ||
endif ( ) | ||
endif ( ) | ||
|
||
# add the threading library | ||
if ( USE_OPENMP ) | ||
# use OpenMP | ||
message ( STATUS "Using OpenMP to synchronize user threads" ) | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} -DUSER_OPENMP_THREADS " ) | ||
elseif ( USE_POSIX ) | ||
# use POSIX | ||
message ( STATUS "Using POSIX pthreads to synchronize user threads" ) | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -DUSER_POSIX_THREADS " ) | ||
else ( ) | ||
# use no threading at all | ||
message ( WARNING "No support for user threads; LAGraph will not be thread-safe" ) | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSER_NO_THREADS " ) | ||
endif ( ) | ||
|
||
if ( CMAKE_USE_PTHREADS_INIT ) | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_PTHREADS " ) | ||
endif ( ) | ||
|
||
if ( CMAKE_USE_WIN32_THREADS_INIT ) | ||
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_WINDOWS_THREADS " ) | ||
endif ( ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# print final C flags | ||
#------------------------------------------------------------------------------- | ||
|
||
message ( STATUS "CMAKE C flags: " ${CMAKE_C_FLAGS} ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# Demo programs | ||
#------------------------------------------------------------------------------- | ||
|
||
file ( GLOB SOURCES "*.c" ) | ||
|
||
add_executable ( extract_test ${SOURCES} ) | ||
|
||
# Libraries required for Demo programs | ||
target_link_libraries ( extract_test graphblas lagraph m ) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#------------------------------------------------------------------------------- | ||
# Test/extract/Makefile | ||
#------------------------------------------------------------------------------- | ||
|
||
# LAGraph, (... list all authors here) (c) 2019, All Rights Reserved. | ||
# http://graphblas.org See LAGraph/LICENSE for license. | ||
|
||
#------------------------------------------------------------------------------- | ||
|
||
# simple Makefile for LAGraph/Test/extract/extract_test, | ||
|
||
# relies on cmake to do the actual build. Use the CMAKE_OPTIONS argument to | ||
# this Makefile to pass options to cmake. | ||
|
||
# Install LAGraph and GraphBLAS before trying to compile LAGraph. | ||
|
||
JOBS ?= 1 | ||
|
||
# build and run test | ||
default: compile | ||
./build/extract_test | ||
|
||
# build test | ||
compile: | ||
( cd build ; cmake $(CMAKE_OPTIONS) .. ; $(MAKE) --jobs=$(JOBS) ) | ||
|
||
# just run cmake; do not compile | ||
cmake: | ||
( cd build ; cmake $(CMAKE_OPTIONS) .. ; ) | ||
|
||
clean: distclean | ||
|
||
purge: distclean | ||
|
||
# remove all files not in the distribution | ||
distclean: | ||
rm -rf build/* extract_test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore all files here except this file. | ||
* | ||
*/ | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
//------------------------------------------------------------------------------ | ||
// LAGraph/Test/extract/extract_test.c: test program for GrB*extractElement | ||
//------------------------------------------------------------------------------ | ||
|
||
/* | ||
LAGraph: graph algorithms based on GraphBLAS | ||
Copyright 2019 LAGraph Contributors. | ||
(see Contributors.txt for a full list of Contributors; see | ||
ContributionInstructions.txt for information on how you can Contribute to | ||
this project). | ||
All Rights Reserved. | ||
NO WARRANTY. THIS MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. THE LAGRAPH | ||
CONTRIBUTORS MAKE NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED, | ||
AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR | ||
PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF | ||
THE MATERIAL. THE CONTRIBUTORS DO NOT MAKE ANY WARRANTY OF ANY KIND WITH | ||
RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. | ||
Released under a BSD license, please see the LICENSE file distributed with | ||
this Software or contact permission@sei.cmu.edu for full terms. | ||
Created, in part, with funding and support from the United States | ||
Government. (see Acknowledgments.txt file). | ||
This program includes and/or can make use of certain third party source | ||
code, object code, documentation and other files ("Third Party Software"). | ||
See LICENSE file for more details. | ||
*/ | ||
|
||
//------------------------------------------------------------------------------ | ||
|
||
// Contributed by Tim Davis, Texas A&M | ||
|
||
// Usage: extract_test | ||
|
||
#include "LAGraph.h" | ||
|
||
#define LAGRAPH_FREE_ALL \ | ||
GrB_free (&X) ; | ||
|
||
#define CHECK(ok) \ | ||
if (!(ok)) \ | ||
{ \ | ||
fprintf (stderr, "fail: %s %d\n", __FILE__, __LINE__) ; \ | ||
printf ("fail: %s %d\n", __FILE__, __LINE__) ; \ | ||
abort ( ) ; \ | ||
} | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
|
||
//-------------------------------------------------------------------------- | ||
// initialize LAGraph and GraphBLAS | ||
//-------------------------------------------------------------------------- | ||
|
||
GrB_Info info ; | ||
GrB_Vector X = NULL ; | ||
LAGraph_init ( ) ; // start LAGraph | ||
|
||
//-------------------------------------------------------------------------- | ||
// construct a nearly-dense vector | ||
//-------------------------------------------------------------------------- | ||
|
||
double tic [2] ; | ||
LAGraph_tic (tic) ; | ||
|
||
GrB_Index n = 64 * 1024 * 1024 ; | ||
printf ("extract test: n = %lu\n", n) ; | ||
LAGr_Vector_new (&X, GrB_UINT64, n) ; | ||
for (uint64_t k = 1 ; k < n ; k++) | ||
{ | ||
LAGr_Vector_setElement (X, k, k) ; | ||
} | ||
|
||
double t = LAGraph_toc (tic) ; | ||
printf ("set time %12.6f n/sec %12.6f million\n", t, 1e-6 * ((double) n-1) / t) ; | ||
|
||
LAGraph_tic (tic) ; | ||
GrB_Index ignore ; | ||
LAGr_Vector_nvals (&ignore, X) ; | ||
t = LAGraph_toc (tic) ; | ||
printf ("wait time %12.6f n/sec %12.6f million\n", t, 1e-6 * ((double) n-1) / t) ; | ||
|
||
LAGraph_tic (tic) ; | ||
GxB_print (X, GxB_SHORT) ; | ||
t = LAGraph_toc (tic) ; | ||
printf ("check time %12.6f n/sec %12.6f million\n", t, 1e-6 * ((double) n-1) / t) ; | ||
|
||
//-------------------------------------------------------------------------- | ||
// test binary searches | ||
//-------------------------------------------------------------------------- | ||
|
||
uint64_t x ; | ||
|
||
for (uint64_t k = 1 ; k < n ; k++) | ||
{ | ||
LAGr_Vector_extractElement (&x, X, k) ; | ||
CHECK (x == k) ; | ||
} | ||
|
||
t = LAGraph_toc (tic) ; | ||
printf ("extract time %12.6f n/sec %12.6f million\n", t, 1e-6 * ((double) n-1) / t) ; | ||
|
||
info = GrB_Vector_extractElement (&x, X, 0) ; | ||
CHECK (info == GrB_NO_VALUE) ; | ||
|
||
LAGRAPH_FREE_ALL ; | ||
LAGraph_finalize ( ) ; | ||
return (GrB_SUCCESS) ; | ||
} | ||
|
Oops, something went wrong.