-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
14 changed files
with
1,017 additions
and
285 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 |
---|---|---|
@@ -1,95 +1,58 @@ | ||
cmake_minimum_required(VERSION 3.19) | ||
project(SCE) | ||
project(cuda_kmers) | ||
set(CMAKE_CXX_STANDARD 14) | ||
cmake_policy(SET CMP0104 OLD) # Can't get CUDA_ARCHITECTURES to work with NEW | ||
|
||
# Variable definitions | ||
set(TARGET_NAME cuda_kmers) | ||
add_compile_definitions(PYTHON_EXT) | ||
|
||
IF(CMAKE_COMPILER_IS_GNUCC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") | ||
ENDIF(CMAKE_COMPILER_IS_GNUCC) | ||
|
||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0") | ||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0") | ||
# Set these to profile | ||
# set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g") | ||
# set(CMAKE_CUDA_FLAGS_RELEASE "-O2 -DUSE_CUDA_PROFILER") | ||
|
||
if(UNIX AND NOT APPLE) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS") | ||
set(CMAKE_LD_FLAGS "${CMAKE_LDFLAGS} -Wl,--as-needed") | ||
endif() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ffast-math -funroll-loops -m64") | ||
|
||
# Set paths for non standard lib/ and include/ locations | ||
if(DEFINED ENV{CONDA_PREFIX}) | ||
include_directories($ENV{CONDA_PREFIX}/include) | ||
link_directories($ENV{CONDA_PREFIX}/lib) | ||
link_directories($ENV{CONDA_PREFIX}/lib/intel64) | ||
else() | ||
find_package(OpenMP) | ||
endif() | ||
|
||
# Add libraries | ||
find_package(Eigen3 3.3 REQUIRED NO_MODULE) | ||
find_package(ZLIB) | ||
find_package(pybind11 REQUIRED) | ||
|
||
# Check for CUDA and compiles GPU library | ||
include(CheckLanguage) | ||
check_language(CUDA) | ||
if(CMAKE_CUDA_COMPILER) | ||
message(STATUS "CUDA found, compiling both GPU and CPU code") | ||
|
||
enable_language(CUDA) | ||
set(CUDA_OPTS "-Wreorder -Xcompiler -fPIC -Xcompiler -Wall -Xcompiler -fopenmp -Xptxas -dlcm=ca --cudart static --relocatable-device-code=false") | ||
string(APPEND CUDA_OPTS " -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86") | ||
if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
string(APPEND CUDA_OPTS " -G") | ||
else() | ||
string(APPEND CUDA_OPTS " --use_fast_math") | ||
endif() | ||
# Set this to profile | ||
# string(APPEND CUDA_OPTS " -pg --generate-line-info") | ||
set(CMAKE_CUDA_FLAGS "${CUDA_OPTS}") | ||
|
||
add_compile_definitions(GPU_AVAILABLE) | ||
add_library("${TARGET_NAME}_CUDA" OBJECT src/wtsne_gpu.cu) | ||
target_include_directories("${TARGET_NAME}_CUDA" PRIVATE "${pybind11_INCLUDE_DIRS}") | ||
set_property(TARGET "${TARGET_NAME}_CUDA" | ||
PROPERTY POSITION_INDEPENDENT_CODE ON | ||
CUDA_SEPARABLE_COMPILATION OFF | ||
CUDA_RESOLVE_DEVICE_SYMBOLS ON # try and ensure device link with nvcc | ||
CUDA_VISIBILITY_PRESET "hidden") | ||
enable_language(CUDA) | ||
set(CUDA_OPTS "-Wreorder -Xcompiler -fPIC -Xcompiler -Wall -Xcompiler -fopenmp -Xptxas -dlcm=ca --cudart static --relocatable-device-code=false") | ||
string(APPEND CUDA_OPTS " -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86") | ||
if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
string(APPEND CUDA_OPTS " -G") | ||
else() | ||
message(STATUS "CUDA not found, compiling CPU code only") | ||
string(APPEND CUDA_OPTS " --use_fast_math") | ||
endif() | ||
|
||
# Compile CPU library | ||
add_library("${TARGET_NAME}" MODULE src/python_bindings.cpp) | ||
# Set this to profile | ||
# string(APPEND CUDA_OPTS " -pg --generate-line-info") | ||
set(CMAKE_CUDA_FLAGS "${CUDA_OPTS}") | ||
|
||
add_library("${TARGET_NAME}" MODULE src/python_bindings.cu) | ||
target_include_directories("${TARGET_NAME}" PRIVATE "${pybind11_INCLUDE_DIRS}") | ||
set_property(TARGET "${TARGET_NAME}" | ||
PROPERTY POSITION_INDEPENDENT_CODE ON | ||
CUDA_SEPARABLE_COMPILATION OFF | ||
CUDA_RESOLVE_DEVICE_SYMBOLS ON # try and ensure device link with nvcc | ||
CUDA_VISIBILITY_PRESET "hidden") | ||
set_target_properties("${TARGET_NAME}" PROPERTIES | ||
CXX_VISIBILITY_PRESET "hidden" | ||
PREFIX "${PYTHON_MODULE_PREFIX}" | ||
SUFFIX "${PYTHON_MODULE_EXTENSION}" | ||
) | ||
if(UNIX AND (NOT APPLE OR NOT CMAKE_COMPILER_IS_GNUCC)) | ||
set_target_properties("${TARGET_NAME}" PROPERTIES | ||
INTERPROCEDURAL_OPTIMIZATION ON) | ||
endif() | ||
|
||
if(CMAKE_CUDA_COMPILER) | ||
target_link_libraries("${TARGET_NAME}" PRIVATE "${TARGET_NAME}_CUDA") | ||
set_property(TARGET "${TARGET_NAME}" PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON) | ||
endif() | ||
CXX_VISIBILITY_PRESET "hidden" | ||
PREFIX "${PYTHON_MODULE_PREFIX}" | ||
SUFFIX "${PYTHON_MODULE_EXTENSION}") | ||
|
||
target_link_libraries("${TARGET_NAME}" PRIVATE pybind11::module) | ||
if(DEFINED ENV{CONDA_PREFIX} AND (NOT APPLE OR CMAKE_COMPILER_IS_GNUCC)) | ||
target_link_libraries("${TARGET_NAME}" PRIVATE gomp z) | ||
else() | ||
target_link_libraries("${TARGET_NAME}" PRIVATE ZLIB::ZLIB) | ||
if(OpenMP_CXX_FOUND) | ||
target_link_libraries("${TARGET_NAME}" PRIVATE OpenMP::OpenMP_CXX) | ||
endif() | ||
endif() |
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,44 @@ | ||
name: gpu_kmer_counter | ||
channels: | ||
- anaconda | ||
- conda-forge | ||
- bioconda | ||
- defaults | ||
dependencies: | ||
- ca-certificates=2020.10.14 | ||
- certifi=2020.6.20 | ||
- cudatoolkit=11.0.221 | ||
- dbus=1.13.18 | ||
- expat=2.2.10 | ||
- fontconfig=2.13.0 | ||
- freetype=2.10.4 | ||
- glib=2.56.2 | ||
- gst-plugins-base=1.14.0 | ||
- gstreamer=1.14.0 | ||
- icu=58.2 | ||
- jpeg=9b | ||
- ld_impl_linux-64=2.33.1 | ||
- libedit=3.1.20191231 | ||
- libffi=3.3 | ||
- libgcc-ng=9.1.0 | ||
- libpng=1.6.37 | ||
- libstdcxx-ng=9.1.0 | ||
- libuuid=1.0.3 | ||
- libxcb=1.14 | ||
- libxml2=2.9.10 | ||
- ncurses=6.2 | ||
- openssl=1.1.1h | ||
- pcre=8.44 | ||
- pip=20.2.4 | ||
- pyqt=5.9.2 | ||
- python=3.8.5 | ||
- qt=5.9.7 | ||
- readline=8.0 | ||
- setuptools=50.3.0 | ||
- sip=4.19.24 | ||
- sqlite=3.33.0 | ||
- tk=8.6.10 | ||
- wheel=0.35.1 | ||
- xz=5.2.5 | ||
- zlib=1.2.11 | ||
prefix: /home/noahaus/miniconda3/envs/gpu_kmer_counter |
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 @@ | ||
import argparse | ||
import psutil | ||
|
||
def cli(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-i','--input',dest='input',help='Provide the path to the input directory with FAST[AQ] files.') | ||
parser.add_argument('-o','--output',dest='out', default="out",help='The name used for the output results.') | ||
parser.add_argument('-k','--k-size',dest='ksize',default=25,help='The k-mer length. Should be a positive integer.') | ||
parser.add_argument('-K','--k-guess',dest='kguess',default=5*10^6,help='The number of approximate k-mers in the input files.') | ||
parser.add_argument('-m','--avail-memory',dest='mem',default=psutil.virtual_memory().available/(1024.0 ** 3),help='The available memory to use the tool. Should be in GB') | ||
parser.add_argument('-f','--false-positive-rate',dest='fpr',default=0.0,help='Set the allowable false positive rate.') | ||
|
||
args = parser.parse_args() | ||
|
||
def extract_cli(): | ||
seq_dir = args.input | ||
k = args.ksize | ||
k_guess = args.kguess | ||
mem = args.mem | ||
fpr = args.fpr | ||
|
||
if not isinstance(k, int) or not isinstance(fpr,float): | ||
sys.exit(0) | ||
else: | ||
print( | ||
""" | ||
Testing to see if values can be extracted: | ||
{} | ||
{} | ||
{} | ||
{} | ||
{} | ||
""".format(seq_dir,k,k_guess,mem,fpr)) | ||
|
||
|
||
|
||
if __name__ == '__cli__': | ||
cli() |
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 |
---|---|---|
@@ -1,6 +1,118 @@ | ||
# Code for user interface | ||
# Author: Noah Legall | ||
# Team: John Lees, Louise Cerdeira, Sam Horsfield, Noah Legall | ||
|
||
def main(): | ||
print("kmers") | ||
from PyQt5 import QtWidgets | ||
from PyQt5.QtWidgets import QWidget, QPushButton, QApplication, QGridLayout, QLabel, QFrame, QFileDialog | ||
from PyQt5.QtWidgets import * | ||
from PyQt5.QtCore import * | ||
from PyQt5.QtGui import * | ||
import sys | ||
|
||
# initializes the window | ||
def window(): | ||
# compulsory lines | ||
app = QApplication(sys.argv) | ||
win = QMainWindow() | ||
|
||
# set window dimensions and window title | ||
# x coord, y coord, width, height | ||
win.setGeometry(400,400,500,300) | ||
win.setWindowTitle("kmer-counter") | ||
|
||
# actually show the window | ||
win.show() | ||
|
||
# wait for the user to click 'x' to close the window | ||
sys.exit(app.exec_()) | ||
|
||
class PyQtLayout(QWidget): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.UI() | ||
self.setFixedHeight(300) | ||
self.setFixedWidth(700) | ||
|
||
def UI(self): | ||
# Text labels for dialog boxes. | ||
label1 = QLabel("input directory:") | ||
label2 = QLabel("k-mer length (bps):") | ||
labelGuess = QLabel("guess # of k-mers") | ||
label3 = QLabel("memory available (MB):") | ||
label4 = QLabel("false positivity rate (0-1):") | ||
|
||
self.line1 = QtWidgets.QLineEdit() | ||
self.line1.setFixedWidth(400) | ||
self.line2 = QtWidgets.QLineEdit() | ||
self.line2.setFixedWidth(150) | ||
self.line3 = QtWidgets.QLineEdit() | ||
self.line3.setFixedWidth(150) | ||
self.line4 = QtWidgets.QLineEdit() | ||
self.line4.setFixedWidth(150) | ||
self.lineGuess = QtWidgets.QLineEdit() | ||
self.lineGuess.setFixedWidth(150) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
launch = QPushButton() | ||
launch.setText("Submit") | ||
launch.clicked.connect(self.extract) | ||
browseLaunch = QPushButton() | ||
browseLaunch.setText("...") | ||
browseLaunch.clicked.connect(self.browse) | ||
|
||
grid = QGridLayout() | ||
grid.addWidget(label1, 0, 0) | ||
grid.addWidget(label2, 1, 0) | ||
grid.addWidget(label3, 2, 0) | ||
grid.addWidget(label4, 3, 0) | ||
grid.addWidget(labelGuess,4,0) | ||
grid.addWidget(self.line1, 0, 1) | ||
grid.addWidget(self.line2, 1, 1) | ||
grid.addWidget(self.line3, 2, 1) | ||
grid.addWidget(self.line4, 3, 1) | ||
grid.addWidget(self.lineGuess,4,1) | ||
grid.addWidget(launch, 5, 0) | ||
grid.addWidget(browseLaunch,0,3) | ||
|
||
self.setLayout(grid) | ||
self.setGeometry(300, 300, 500, 200) | ||
self.setWindowTitle('kmer-counter') | ||
self.show() | ||
|
||
def browse(self): | ||
response = QFileDialog.getExistingDirectory( | ||
self, | ||
caption='Select Folder' | ||
) | ||
print(response) | ||
self.line1.setText(response) | ||
return response | ||
|
||
def extract(self): | ||
seq_dir = self.line1.text() | ||
k = int(self.line2.text()) | ||
k_guess = int(self.lineGuess.text()) | ||
mem = int(self.line3.text()) | ||
fpr = float(self.line4.text()) | ||
|
||
if not isinstance(k, int) or not isinstance(fpr,float): | ||
sys.exit(0) | ||
else: | ||
print( | ||
""" | ||
Testing to see if values can be extracted: | ||
{} | ||
{} | ||
{} | ||
{} | ||
{} | ||
""".format(seq_dir,k,k_guess,mem,fpr)) | ||
|
||
|
||
def main(): | ||
app = QApplication(sys.argv) | ||
ex = PyQtLayout() | ||
sys.exit(app.exec_()) | ||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.