Skip to content
Open
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
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ For the padded version:
We recommend compiling CCMpred on the machine that should run the computations so that it can be optimized for the appropriate CPU/GPU architecture.

### Downloading
If you want to compile the most recent version, use the follwing to clone both CCMpred and its submodules:
If you want to compile the most recent version, use the following to clone the latest version of CCMpred:

git clone --recursive https://github.com/soedinglab/CCMpred.git
git clone https://github.com/soedinglab/CCMpred.git

### Compilation
With the sourcecode ready, simply run cmake with the default settings and libraries should be auto-detected:
Expand Down
1 change: 0 additions & 1 deletion lib/libconjugrad
Submodule libconjugrad deleted from e503ee
55 changes: 55 additions & 0 deletions lib/libconjugrad/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
### C

# Object files
*.o
*.ko
*.obj
*.elf

#Binaries
/bin

# Libraries
*.lib
*.a

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex


### vim

[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~


### CMake

CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
install_manifest.txt
_build


### Python

__pycache__/
*.py[cod]

120 changes: 120 additions & 0 deletions lib/libconjugrad/.ycm_extra_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

import os
import ycm_core

flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',

'-std=c11',
'-x',
'c',
'-I',
'./include'
]


# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''

if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None

SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]

def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )


def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag

if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )

for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break

if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break

if new_flag:
new_flags.append( new_flag )
return new_flags


def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]


def GetCompilationInfoForFile( filename ):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
compilation_info = database.GetCompilationInfoForFile(
replacement_file )
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile( filename )


def FlagsForFile( filename, **kwargs ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None

final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )

# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
try:
final_flags.remove( '-stdlib=libc++' )
except ValueError:
pass
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )

return {
'flags': final_flags,
'do_cache': True
}
64 changes: 64 additions & 0 deletions lib/libconjugrad/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
cmake_minimum_required(VERSION 3.8)
include(CheckLanguage)

project(libconjugrad)
set(LIBCONJUGRAD_MAJOR_VERSION 0)
set(LIBCONJUGRAD_MINOR_VERSION 0)
set(LIBCONJUGRAD_PATCH_VERSION 4)
set(LIBCONJUGRAD_VERSION ${LIBCONJUGRAD_MAJOR_VERSION}.${LIBCONJUGRAD_MINOR_VERSION}.${LIBCONJUGRAD_PATCH_VERSION})

if(CMAKE_VERSION VERSION_GREATER 2.8.11)
cmake_policy(SET CMP0022 OLD)
endif(CMAKE_VERSION VERSION_GREATER 2.8.11)

set(CMAKE_C_FLAGS "-std=c99 -O3 -g -lm")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

include_directories("${PROJECT_SOURCE_DIR}/include")

set(SOURCES src/conjugrad.c src/debug.c)

if(NOT DEFINED WITH_SIMD)
set(WITH_SIMD ansi)
endif(NOT DEFINED WITH_SIMD)

if(NOT DEFINED WITH_CUDA)
set(WITH_CUDA ON)
endif(NOT DEFINED WITH_CUDA)

if(WITH_SIMD STREQUAL ansi)
add_definitions(-DCONJUGRAD_SIMD=0)
list(APPEND SOURCES src/arithmetic_ansi.c)
elseif(WITH_SIMD STREQUAL sse)
add_definitions(-DCONJUGRAD_SIMD=1)
list(APPEND SOURCES src/arithmetic_simd.c)
elseif(WITH_SIMD STREQUAL avx)
add_definitions(-DCONJUGRAD_SIMD=2)
list(APPEND SOURCES src/arithmetic_simd.c)
endif(WITH_SIMD STREQUAL ansi)

set(BUILD_SHARED_LIBS OFF)

if(WITH_CUDA)
find_package(CUDA)
check_language(CUDA)
enable_language(CUDA)

#list(APPEND SOURCES src/conjugrad_cuda.c src/help_functions.cu src/conjugrad_kernels.cu)
list(APPEND SOURCES src/conjugrad_cuda.c src/conjugrad_kernels.cu)

include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
endif(WITH_CUDA)

add_library(conjugrad ${SOURCES})

install(TARGETS conjugrad DESTINATION lib)

add_executable(rosenbrock EXCLUDE_FROM_ALL samples/rosenbrock.c)
target_link_libraries(rosenbrock conjugrad)

add_executable(polynomial EXCLUDE_FROM_ALL samples/polynomial.c)
target_link_libraries(polynomial conjugrad)

add_executable(sphere EXCLUDE_FROM_ALL samples/sphere.c)
target_link_libraries(sphere conjugrad)
34 changes: 34 additions & 0 deletions lib/libconjugrad/include/arithmetic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef CONJUGRAD_ARITHMETIC_H
#define CONJUGRAD_ARITHMETIC_H

#include "conjugrad.h"


// set all vector elements to 0
void vec0(conjugrad_float_t *dst, int n);

// copy src onto dst
void veccpy(conjugrad_float_t *dst, conjugrad_float_t *src, int n);

// dst += src
//void veciaddv(conjugrad_float_t *dst, conjugrad_float_t *src, int n);

// dst *= f
void vecimulc(conjugrad_float_t *dst, conjugrad_float_t f, int n);

// dst -= f * src
void vecifma(conjugrad_float_t *dst, conjugrad_float_t *src, conjugrad_float_t f, int n);

// dst = f * b - a
void vecsfms(conjugrad_float_t *dst, conjugrad_float_t *a, conjugrad_float_t f, conjugrad_float_t *b, int n);

// dst = sum_n v[n] * w[n]
conjugrad_float_t vecdot(conjugrad_float_t *v, conjugrad_float_t *w, int n);

// dst = sum_n v[n]^2
conjugrad_float_t vecnorm(conjugrad_float_t *v, int n);


conjugrad_float_t *vecalloc(int n);

#endif
Loading