Thursday 19 April 2018

SPO600 - Phase 3 - Trying to get that optimization upstream

Finally we move on to final step in which I am will be discussing about Is my optimization worth to get upstream? and if yes how should I try to get upstream? Firstly the optimizations I made are not too extreme as I am only changing compiler flags from -O0 to -O2 and -O3 in which -O2 gave me pretty bad performance while -O3 helped me improve some performance.


The performance speed up which I achieved from -O3 wasn't too impressing it just seems to give normal boost to the program by turning off few gateways but I assume as it produced more compiler code or there could be some other reason due to which it was lagging as I didn't get the result I expected. But still I am trying to figure if I could make any kind of changes in make files as I know that ./configure uses -O2 to compile its make files. As I was going through make files they were coded to perfection there was nothing I could change to make program run faster. I have mentioned before in of my blogs before that this program was improved last in 2014 since then there have been no updates or any kind of modification to it.


On further note I was going through all configure files if I could find something relevant to the flags. Luckily I ended up finding something valuable in configure.ac what I noticed was that it was having PTHREAD support this library was getting initialized to any of the in built flags which are used to make files like CFFLAGS or CXXFLAGS as you can see below code seems to be pretty complicated. I was wondering if there could be a way where could find which flags are suitable to get better performance in PTHREAD support but they might be hidden somewhere in the code.

# PTHREAD support
# With special nods to compiling under mingw

if test  x"$mingw" = x"yes";  then
  AC_MSG_NOTICE([Checking for pthreads under mingw])
  AC_DEFINE([HAVE_STRUCT_TIMESPEC],1,[Required for mingw])
  CFLAGS="$CFLAGS -mthreads "
  CPPFLAGS="-DPTW32_STATIC_LIB $CPPFLAGS"
  CXXFLAGS="$CXXFLAGS -mthreads "
  AC_DEFINE(HAVE_PTHREAD,1,[Defined to POSIX threads for mingw])
else
  m4_include([m4/ax_pthread.m4])
  AX_PTHREAD([
    echo Using settings from [AX_PTHREAD] macro
    LIBS="$PTHREAD_LIBS $LIBS"
    CFLAGS="  $PTHREAD_CFLAGS $CFLAGS"
    CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS "
    CPPFLAGS="$PTHREAD_CFLAGS $CPPFLAGS "
    CC="$PTHREAD_CC"
    AC_DEFINE(HAVE_PTHREAD,1,[Defined to POSIX threads for mingw])
  ],[AC_MSG_NOTICE([pthreads not found by ax_pthread macro])])
fi

AC_CHECK_HEADERS([pthread.h])
AC_CHECK_LIB([pthreadGC2],[pthread_create])

# On mingw, be sure to use the static version and be sure we are using mthread option
# (which should be a no-op on later version of G++ anyway)

AC_CHECK_FUNCS([pthread_win32_process_attach_np pthread_win32_process_detach_np pthread_win32_thread_attach_np pthread_win32_thread_detach_np])
# end PTHREAD SUPPORT

Finally I came uo no solution to upstream my code nor I could contact open source community for their help as I have no valid proof changes what I have made changes is appropriate.




No comments:

Post a Comment