Skip to content

Commit

Permalink
Fix openMP issues (#716)
Browse files Browse the repository at this point in the history
* Set the numpy threading environment variables in every program before anything else is imported.

* PEP8
  • Loading branch information
dpryan79 authored Jun 8, 2018
1 parent 5ccac90 commit 2122179
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/alignmentSieve
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.alignmentSieve import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/bamCompare
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.bamCompare import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/bamCoverage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.bamCoverage import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/bamPEFragmentSize
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.bamPEFragmentSize import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/bigwigCompare
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.bigwigCompare import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/computeGCBias
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.computeGCBias import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/computeMatrix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.computeMatrix import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/computeMatrixOperations
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.computeMatrixOperations import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/correctGCBias
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.correctGCBias import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/deeptools
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.deeptools_list_tools import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/estimateReadFiltering
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import deeptools.misc
from deeptools.estimateReadFiltering import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/estimateScaleFactor
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
import argparse
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/multiBamSummary
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.multiBamSummary import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/multiBigwigSummary
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.multiBigwigSummary import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/plotCorrelation
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.plotCorrelation import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/plotCoverage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import deeptools.misc
from deeptools.plotCoverage import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/plotEnrichment
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import deeptools.misc
from deeptools.plotEnrichment import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/plotFingerprint
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.plotFingerprint import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/plotHeatmap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.plotHeatmap import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/plotPCA
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.plotPCA import main
import sys

Expand Down
1 change: 1 addition & 0 deletions bin/plotProfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
from deeptools.plotProfile import main
import sys

Expand Down
13 changes: 13 additions & 0 deletions deeptools/misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os

# This should force numpy to run single threaded. See issue #697
# This module MUST be imported before numpy
# Note that these environment variables are internal to deepTools (they won't exist on the shell after the command completes)
if 'MKL_NUM_THREADS' not in os.environ:
os.environ['MKL_NUM_THREADS'] = 'sequential'
if 'NUMEXPR_NUM_THREADS' not in os.environ:
os.environ['NUMEXPR_NUM_THREADS'] = '1'
if 'OMP_NUM_THREADS' not in os.environ:
os.environ['OMP_NUM_THREADS'] = '1'
if 'VECLIB_MAXIMUM_THREADS' not in os.environ:
os.environ['VECLIB_MAXIMUM_THREADS'] = '1'

0 comments on commit 2122179

Please sign in to comment.