ó
àÆ÷Xc           @` s2  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l	 m
 Z
 d  d l Z d  d l m Z e
 ƒ  Z e d d ƒ Z e j d d	 d
 d d d d e j j d d d d ƒd „  Z e d k r.e j e j ƒ \ Z Z e e d ƒ r!e e j ƒ e j d  ƒ n  e j j d d ƒ Z e d e j d <e d e j  ƒ \ Z! Z" e d e j d <e d e j  ƒ \ Z# Z$ e! e# k r§e! e# Z% d Z& n e# e! Z% d Z& e" e$ k rÖe" e$ Z' d Z( n e$ e" Z' d Z( e d e j  ƒ e d e! e# e& e% f ƒ e d e" e$ e( e' f ƒ n  d S(   i    (   t   absolute_importt   print_functiont   divisionN(   t   OptionParser(   t   getpreferredencoding(   t   decode_witht   usagesC   %prog <options>
 Compute time for fast and slow elemwise operationss   -Ns   --Nt   actiont   storet   destt   Nt   defaultt   typet   intt   helps   Number of vector elementsc         C` s´   d } t  j j t  j j t ƒ ƒ } t j d | d d t |  ƒ g d t j d t j d | ƒ} | j	 ƒ  \ } } | r t
 | ƒ t j ƒ  n  t t t t | t ƒ j d ƒ ƒ ƒ S(	   Ns   elemwise_time_test.pyt   pythons   --scripts   -Nt   stdoutt   stderrt   cwdt    (   t   ost   patht   dirnamet   abspatht   __file__t
   subprocesst   Popent   strt   PIPEt   communicatet   printt   syst   exitt   listt   mapt   floatR   t   console_encodingt   split(   R
   t   scriptR   t   proct   outt   err(    (    sC   /tmp/pip-build-X4mzal/theano/theano/misc/elemwise_openmp_speedup.pyt	   runScript   s    !	
t   __main__t   THEANO_FLAGSt    s   ,openmp=falses   ,openmp=truet   speedupt   slowdowns    Timed with vector of %d elementss8   Fast op time without openmp %fs with openmp %fs %s %2.2fs8   Slow op time without openmp %fs with openmp %fs %s %2.2f()   t
   __future__R    R   R   R   R   R   t   optparseR   t   localeR   t   theanot   theano.compatR   R$   t   parsert
   add_optiont   configt   openmp_elemwise_minsizeR*   t   __name__t
   parse_argst   argvt   optionst	   argumentst   hasattrR   R   R    t   environt   gett
   orig_flagsR
   t	   cheapTimet
   costlyTimet   cheapTimeOpenmpt   costlyTimeOpenmpt
   cheapSpeedt   cheapSpeedstringt   costlySpeedt   costlySpeedstring(    (    (    sC   /tmp/pip-build-X4mzal/theano/theano/misc/elemwise_openmp_speedup.pyt   <module>   sL   		
	

	
