mailr23640 - in /branches/frame_order_cleanup: ./ sconstruct user_functions/relax_disp.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on June 04, 2014 - 18:39:
Author: bugman
Date: Wed Jun  4 18:39:16 2014
New Revision: 23640

URL: http://svn.gna.org/viewcvs/relax?rev=23640&view=rev
Log:
Merged revisions 23637-23639 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r23637 | bugman | 2014-06-04 16:56:17 +0200 (Wed, 04 Jun 2014) | 9 lines
  
  Expanded and improved the docstring for the relax_disp.r20_from_min_r2eff 
user function.
  
  This follows from 
http://thread.gmane.org/gmane.science.nmr.relax.devel/5957.
  
  The documentation now covers a number of the uses for this user function.  
The text has also been
  lightly edited.  To fit all the text into the GUI user function window, the 
size of the dialog and
  the text high settings have been changed.
........
  r23638 | bugman | 2014-06-04 18:05:35 +0200 (Wed, 04 Jun 2014) | 12 lines
  
  Large improvements for the detection of cross-compilation on Mac OS X 
systems.
  
  The tests for different architecture support now follows the ideas 
discussed in the post
  http://thread.gmane.org/gmane.science.nmr.relax.devel/5785/focus=5820.
  
  In summary, for each architecture a simple C file is created, compiled with 
'gcc -arch xyz', and the
  resultant binary file tested.  To support 64-bit compilation on 32-bit 
systems, all previously
  successful architectures are also included in the gcc command.
  
  The change allows the 'ppc64' architecture to be reintroduced.
........
  r23639 | bugman | 2014-06-04 18:21:30 +0200 (Wed, 04 Jun 2014) | 5 lines
  
  Fixed the docstring for the det_arch() method of the sconstruct script.
  
  This is for the true cross-compilation detection on Mac OS X.
........

Modified:
    branches/frame_order_cleanup/   (props changed)
    branches/frame_order_cleanup/sconstruct
    branches/frame_order_cleanup/user_functions/relax_disp.py

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jun  4 18:39:16 2014
@@ -1 +1 @@
-/trunk:1-23635
+/trunk:1-23639

Modified: branches/frame_order_cleanup/sconstruct
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/sconstruct?rev=23640&r1=23639&r2=23640&view=diff
==============================================================================
--- branches/frame_order_cleanup/sconstruct     (original)
+++ branches/frame_order_cleanup/sconstruct     Wed Jun  4 18:39:16 2014
@@ -4,7 +4,7 @@
 
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2006-2013 Edward d'Auvergne                                  
 #
+# Copyright (C) 2006-2014 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -25,12 +25,13 @@
 
 
 # Import statements.
-from os import getcwd, path, remove, rmdir, sep, walk
+from os import F_OK, access, getcwd, path, remove, rmdir, sep, walk
 import platform
 from re import search
 from shutil import rmtree
 from subprocess import PIPE, Popen
 import sys
+from tempfile import mkdtemp
 
 # Scons modules.
 from scons.distrib import package, gpg_sign
@@ -443,28 +444,64 @@
 
 
     def det_arch(self):
-        """Nasty hack to make Scons behave properly with cross-compilation 
on Mac OS X!
-
-        @return:    The list of CPU architects to cross compile.
+        """Determine which architectures are supported for cross-compilation 
on Mac OS X.
+
+        @return:    The list of CPU architects to cross-compile.
         @rtype:     list of str
         """
 
+        # Printout.
+        print("\nDetermining which architectures can be cross compiled for.")
+
+        # Create a temporary directory for compilation tests.
+        tempdir = mkdtemp()
+
         # The list of archectures to try.
-        archs = ['i386', 'ppc', 'x86_64']
+        archs = ['i386', 'ppc', 'x86_64', 'ppc64']
         allowed = []
 
-        # Loop over each arch and test it.
-        for arch in archs:
-            # Run gcc.
-            pipe = Popen('gcc -arch %s' % arch, shell=True, stdin=PIPE, 
stdout=PIPE, stderr=PIPE, close_fds=False)
-
-            # Loop over the error lines.
-            for line in pipe.stderr.readlines():
-                # Successful arch.
-                if search("no input files", line):
-                    allowed.append(arch)
+        # Safely loop over each arch and test it.
+        try:
+            for arch in archs:
+                # Create a C file to compile.
+                base_name = tempdir + sep + 'test'
+                file = open(base_name + '.c', 'w')
+                file.write("#include<stdio.h>\n\n")
+                file.write("main() {\n")
+                file.write("    printf(\"Compilation with arch '%s' 
successful.\\n\");\n" % arch)
+                file.write("}\n")
+                file.close()
+
+                # Run gcc.
+                arch_test = ''
+                for name in allowed:
+                    arch_test += '-arch %s ' % name
+                pipe = Popen('gcc %s -arch %s %s.c -o %s' % (arch_test, 
arch, base_name, base_name), shell=True, stdin=PIPE, stdout=PIPE, 
stderr=PIPE, close_fds=False)
+                for line in pipe.stdout.readlines():
+                    pass
+
+                # Execute the file.
+                pipe = Popen('%s' % base_name, shell=True, stdin=PIPE, 
stdout=PIPE, stderr=PIPE, close_fds=False)
+
+                # Check the output.
+                for line in pipe.stdout.readlines():
+                    # Printout.
+                    print("    %s" % line[:-1])
+
+                    # Successful arch.
+                    if search("successful", line):
+                        allowed.append(arch)
+
+                # Delete the compiled file, if it exists.
+                if access(base_name, F_OK):
+                    remove(base_name)
+
+        # Clean up.
+        finally:
+            rmtree(tempdir)
 
         # Return the list.
+        print("\n")
         return allowed
 
 
@@ -542,8 +579,9 @@
         # Relaxation curve fitting build environment.
         env = Environment()
 
-        # Determine the build architectures.
-        archs = self.det_arch()
+        # Determine the cross-compilation architectures for Mac systems.
+        if env['PLATFORM'] == 'darwin':
+            archs = self.det_arch()
 
         # C flags.
         if SYSTEM == 'Windows':

Modified: branches/frame_order_cleanup/user_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/user_functions/relax_disp.py?rev=23640&r1=23639&r2=23640&view=diff
==============================================================================
--- branches/frame_order_cleanup/user_functions/relax_disp.py   (original)
+++ branches/frame_order_cleanup/user_functions/relax_disp.py   Wed Jun  4 
18:39:16 2014
@@ -936,13 +936,14 @@
 )
 # Description.
 uf.desc.append(Desc_container())
-uf.desc[-1].add_paragraph("Set the R20 parameter values to that of the 
minimum R2eff value.  This user function will look through all R2eff values 
per magnetic field strength, and find the minimum.  This minimum is a very 
good guess for the minimisation.")
-uf.desc[-1].add_paragraph("Instead of making the grid search find initial 
values of the R20 parameter, the minimum for the R2eff points are used 
instead.  For example for a two field CPMG experiment with model CR72, that 
would drop the number of uniform grid search points from 5D to 3D.  For 
standard 21 grid increments per dimension, it would make the grid search 441 
times faster.")
-uf.desc[-1].add_paragraph("This is an experimental unpublished feature of 
the dispersion analysis.  If R20 << min(R2eff), the grid search will be 
performed in a region of the optimisation space quite distant from the true 
minimum.  If unsure, do not activate this option, and let the grid search 
find a better starting value.")
+uf.desc[-1].add_paragraph("Set the R20 parameter values to that of the 
minimum R2eff value.  This user function will look through all R2eff values 
per magnetic field strength, find the minimum value, and set the R20, R20A, 
R20B, and R1rho' parameters of the model to this value.  This can serve a 
number of purposes including using the values for the chi-squared space 
mapping via the dx.map user function, speeding up optimisation by avoiding 
the grid search for these parameters, and as initial parameter values for 
other dispersion software.")
+uf.desc[-1].add_paragraph("Instead of finding the initial values for the R20 
parameter using the grid search, the minimum for the R2eff points can be used 
instead.  This is often a good initial position for minimisation.  For 
example for a two field CPMG experiment with model CR72, that would drop the 
number of uniform grid search points from 5D to 3D, i.e. two orders of 
magnitude faster.  When using the standard 21 grid increments per dimension, 
it would allow the grid search to be 441 times faster.  Note that the 
relaxation dispersion auto-analysis will take all pre-set parameter values 
into account and will automatically exclude these from the grid search.")
+uf.desc[-1].add_paragraph("Note that for optimisation, that this is an 
experimental and unpublished feature of the dispersion analysis.  If R20 << 
min(R2eff), the grid search will be performed in a region of the optimisation 
space quite distant from the true minimum.  If unsure, do not activate this 
option, and let the grid search find a better starting value.")
 uf.backend = r20_from_min_r2eff
 uf.menu_text = "&r20_from_min_r2eff"
 uf.gui_icon = "relax.grid_search"
-uf.wizard_size = (800, 500)
+uf.wizard_height_desc = 500
+uf.wizard_size = (900, 600)
 uf.wizard_apply_button = False
 
 




Related Messages


Powered by MHonArc, Updated Wed Jun 04 19:40:02 2014