+- +-
Say hello if visiting :) by Gecko
11 Jan 2023, 07:43:05 pm

Seti is down again by Mike
09 Aug 2017, 10:02:44 am

Some considerations regarding OpenCL MultiBeam app tuning from algorithm view by Raistmer
11 Dec 2016, 06:30:56 am

Loading APU to the limit: performance considerations by Mike
05 Nov 2016, 06:49:26 am

Better sleep on Windows - new round by Raistmer
26 Aug 2016, 02:02:31 pm

Author Topic: optimized sources  (Read 548904 times)

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #120 on: 05 Jun 2007, 07:10:38 pm »
keine hektick Crunch3r, alles bestens, hast alle fragen beantwortet <freu>  ;) i

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #121 on: 05 Jun 2007, 07:38:19 pm »
und hier ist der neue client  ;D
------ Neues Erstellen gestartet: Projekt: seti_boinc, Konfiguration: Release32-NOGFX Win32 ------
Die Zwischen- und Ausgabedateien für das Projekt "seti_boinc" mit der Konfiguration "Release32-NOGFX|Win32" werden gelöscht.
Kompilieren...
Microsoft (R) 32-Bit C/C++-Optimierungscompiler Version 14.00.50727.762 für 80x86
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
cl /O2 /Ob2 /Oi /Ot /Oy /GT /I "C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\client\win_build\Release32-NOGFX" /I "C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\jpeglib" /I "C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\image_libs" /I "C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\glut" /I "C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\client\win_build" /I "C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\client\Optimizer" /I "C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe" /I "C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\client" /I "C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\db" /I "C:\I\SC\seti\boinc\client\win" /I "C:\I\SC\seti\boinc\lib" /I "C:\I\SC\seti\boinc\api" /I "C:\I\SC\seti\boinc" /I "." /I "../../../boinc/api" /I "../../../boinc/lib" /I ".." /I "glut" /D "WIN32" /D "_WIN32" /D "NDEBUG" /D "_WINDOWS" /D "NBOINC_APP_GRAPHICS" /D "CLIENT" /D "_MT" /D "USE_IPP" /D "USE_SSE2" /D "_VC80_UPGRADE=0x0600" /D "_MBCS" /GF /Gm /EHsc /MT /Zp16 /Gy /Fp".\Release/seti_boinc.pch" /Fo".\Release32-NOGFX\\" /Fd".\Release32-NOGFX\vc80.pdb" /FR".\Release32-NOGFX\\" /W3 /c /Wp64 /Zi /TP "..\..\db\xml_util.cpp"
   "..\worker.cpp"
   "..\..\..\boinc\api\windows_opengl.C"
   "..\version.cpp"
   "..\..\..\boinc\lib\util.C"
   "..\timecvt.cpp"
   "..\..\image_libs\tgalib.cpp"
   "..\..\db\sqlrow.cpp"
   "..\..\db\sqlblob.cpp"
   "..\spike.cpp"
   "..\..\..\boinc\lib\shmem.C"
   "..\seti_header.cpp"
   "..\seti.cpp"
   "..\..\db\schema_master.cpp"
   "..\sah_gfx_base.cpp"
   "..\sah_gfx.cpp"
   "..\s_util.cpp"
   "..\pulsefind.cpp"
   "..\progress.cpp"
   "..\..\..\boinc\lib\parse.C"
   "..\malloc_a.cpp"
   "..\main.cpp"
   "..\lcgamm.cpp"
   "..\..\..\boinc\api\gutil.C"
   "..\..\..\boinc\api\graphics_data.C"
   "..\..\..\boinc\api\graphics_api.C"
   "..\gdata.cpp"
   "..\gaussfit.cpp"
   "..\..\..\boinc\lib\filesys.C"
   "..\fft8g.cpp"
   "..\chirpfft.cpp"
   "..\..\..\boinc\api\boinc_api.C"
   "..\..\..\boinc\lib\app_ipc.C"
   "..\analyzeReport.cpp"
   "..\analyzePoT.cpp"
   "..\analyzeFuncs.cpp"
analyzeFuncs.cpp
-----IPP-----
-----SSE2-----
analyzePoT.cpp
--- BenSpectrum ---
analyzeReport.cpp
app_ipc.C
boinc_api.C
chirpfft.cpp
fft8g.cpp
filesys.C
gaussfit.cpp
gdata.cpp
graphics_api.C
graphics_data.C
gutil.C
lcgamm.cpp
main.cpp
malloc_a.cpp
parse.C
progress.cpp
pulsefind.cpp
s_util.cpp
Code wird generiert...
Kompilieren...
sah_gfx.cpp
sah_gfx_base.cpp
schema_master.cpp
seti.cpp
seti_header.cpp
..\seti_header.cpp(93) : warning C4267: 'Initialisierung': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
shmem.C
spike.cpp
sqlblob.cpp
sqlrow.cpp
tgalib.cpp
timecvt.cpp
util.C
version.cpp
windows_opengl.C
worker.cpp
xml_util.cpp
Code wird generiert...
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\db\xml_util.cpp(663) : warning C4717: 'xml_match_tag': Rekursiv für alle Steuerelementpfade. Die Funktion verursacht einen Stapelüberlauf zur Laufzeit.
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\db\xml_util.cpp(689) : warning C4717: 'xml_find_tag': Rekursiv für alle Steuerelementpfade. Die Funktion verursacht einen Stapelüberlauf zur Laufzeit.
Verknüpfen...
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.
"/OUT:.\Release32-NOGFX\seti_boinc.exe" /INCREMENTAL:NO "/LIBPATH:C:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\client\win_build\Release32-NOGFX" "/LIBPATH:C:\I\INTEL\IPP\5.2_beta\ia32\lib" "/LIBPATH:C:\I\INTEL\MKL\9.0\ia32\lib" "/LIBPATH:C:\masm32\lib" "/LIBPATH:C:\I\VS8\VC\lib" "/LIBPATH:C:\I\SDK\Lib" "/LIBPATH:C:\masm32\m32lib" "/LIBPATH:C:\I\SDK\Lib\AMD64" "/LIBPATH:C:\I\SDK\Lib\IA64" /MANIFEST:NO "/PDB:c:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\client\win_build\Release32-NOGFX\seti_boinc.pdb" /MAP /SUBSYSTEM:WINDOWS /MACHINE:X86 glut32.lib glut.lib glu32.lib optimizer.lib image_libs.lib jpeglib.lib libboinc.lib libboincapi.lib non_ICC.lib setiboincdb.lib ippsmerged.lib ippvmmerged.lib ippchmerged.lib ippcorel.lib delayimp.lib libcpmt.lib WinMM.lib OpenGL32.lib Kernel32.Lib oldnames.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
".\Release32-NOGFX\analyzeFuncs.obj"
".\Release32-NOGFX\analyzePoT.obj"
".\Release32-NOGFX\analyzeReport.obj"
".\Release32-NOGFX\app_ipc.obj"
".\Release32-NOGFX\boinc_api.obj"
".\Release32-NOGFX\chirpfft.obj"
".\Release32-NOGFX\fft8g.obj"
".\Release32-NOGFX\filesys.obj"
".\Release32-NOGFX\gaussfit.obj"
".\Release32-NOGFX\gdata.obj"
".\Release32-NOGFX\graphics_api.obj"
".\Release32-NOGFX\graphics_data.obj"
".\Release32-NOGFX\gutil.obj"
".\Release32-NOGFX\lcgamm.obj"
".\Release32-NOGFX\main.obj"
".\Release32-NOGFX\malloc_a.obj"
".\Release32-NOGFX\parse.obj"
".\Release32-NOGFX\progress.obj"
".\Release32-NOGFX\pulsefind.obj"
".\Release32-NOGFX\s_util.obj"
".\Release32-NOGFX\sah_gfx.obj"
".\Release32-NOGFX\sah_gfx_base.obj"
".\Release32-NOGFX\schema_master.obj"
".\Release32-NOGFX\seti.obj"
".\Release32-NOGFX\seti_header.obj"
".\Release32-NOGFX\shmem.obj"
".\Release32-NOGFX\spike.obj"
".\Release32-NOGFX\sqlblob.obj"
".\Release32-NOGFX\sqlrow.obj"
".\Release32-NOGFX\tgalib.obj"
".\Release32-NOGFX\timecvt.obj"
".\Release32-NOGFX\util.obj"
".\Release32-NOGFX\version.obj"
".\Release32-NOGFX\windows_opengl.obj"
".\Release32-NOGFX\worker.obj"
".\Release32-NOGFX\xml_util.obj"
Browseinformationsdatei wird erstellt...
Microsoft Browse Information Maintenance-Programm Version 8.00.50727
Copyright (C) Microsoft Corporation. All rights reserved.
Das Buildprotokoll wurde unter "file://c:\I\SC\seti\seti_boinc_2k3_2.2B-Ben-Joe\client\win_build\Release32-NOGFX\BuildLog.htm" gespeichert.
seti_boinc - 0 Fehler, 3 Warnung(en)
========== Alles neu erstellen: 1 erfolgreich, Fehler bei 0, 0 übersprungen ==========

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #122 on: 06 Jun 2007, 04:31:48 am »
...
--------------------------------------------------------------------------------------
47       overhead = std::min(overhead, ticks);

74      min_ticks = std::min(min_ticks, ticks);
--------------------------------------------------------------------------------------
any suggestions ???
I don't know if my solution would be the best or fastest, but i hope it works (just basic C) :

overhead = (overhead <= ticks) ? overhead : ticks;
min_ticks = (min_ticks <= ticks) ? min_ticks : ticks;


Merci Urs  ;)

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #123 on: 06 Jun 2007, 05:10:54 am »
Thank you very much,

all of you, who supported me on the long way to the client, reading my threads, answered my questions and give me hints and tips to bring the application forward to a sucessful compiled version.
Especially thanks to Crunch3r, Josef Segur, Simon and Urs Echternacht.

Now the next step is test, debug and work with test WU´s, to show that this client is really errorfree.
If this is so, I will download the Intel compiler to produce the speed-optimized version of this client, for everybody using.

Hoping at your further support to realize this.

Regards seti_britta ~heinz


Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #124 on: 06 Jun 2007, 07:56:21 am »
This is the first try to run the client with a test WU
How you see it crashes early at the beginning. Searching now, why this happen.
KWSN_2.2B shows what it should do.
--------------------------------------------------------------------------------------------
Can't set up shared mem: -1
Unhandled Exception Detected...

- Unhandled Exception Record -
Reason: Stack Overflow (0xc00000fd) at address 0x7C9281B8

Engaging BOINC Windows Runtime Debugger...

********************

BOINC Windows Runtime Debugger Version 5.5.0

Dump Timestamp    : 06/06/07 13:13:14
LoadLibraryA( symsrv.dll ): GetLastError = 126
LoadLibraryA( srcsrv.dll ): GetLastError = 126
Can't set up shared mem: -1
--------------------------------------------------------------------------------------------
KWSN_2.2B

------- [ benchmark ] --------
               PowerSpectrum--:  14544120 x1.00        0 -- [ avg magnitude =   1.8306 (50)]
                    sse_GetTPS:  14802484 x0.98        0
                     hand_sse2:   6885508 x2.11        0
                   sse2_GetTPS:   7181316 x2.03        0
    PowerSpectrum--[hand_sse2]:   6885508 (chosen)
------------------------------
                PwrSpectOnly--:    897144 x1.00        0 -- [ avg magnitude =   1.8306 (50)]
                sse_GetPSO_npr:    783748 x1.14        0
                sse_GetPSO_p32:    856640 x1.05        0
                sse_GetPSO_p64:    850568 x1.05        0
               sse_GetPSO_p128:    844984 x1.06        0
PwrSpectOnly--[sse_GetPSO_npr]:    783748 (chosen)
------------------------------
                   Transpose--:  16412208 x1.00        0 -- [ avg magnitude =   0.9994 (50)]
                    Transpose2:   8550568 x1.92        0
                    Transpose4:   4740412 x3.46        0
                 sse_Trans4ntw:   2524936 x6.50        0
             sse_pfTrans8x4ntw:   2591696 x6.33        0
    Transpose--[sse_Trans4ntw]:   2524936 (chosen)
------------------------------
                   ChirpData--: 225408392 x1.00        0 -- [ avg magnitude =   0.9727 (10)]
                     TrigArray:  61711612 x3.65 1.6e-009
                  sse1_akChirp:  31697636 x7.11 1.1e-008
                  sse2_akChirp:  26079180 x8.64 1.1e-008
     ChirpData--[sse2_akChirp]:  26079180 (chosen)
------------------------------
                     GetPeak--:    268072 x1.00        0 -- [ avg magnitude =   0.9727 (50)]
                      hand_opt:    273164 x0.98   3e-007 t=-39719.3711 o=-39719.3594
                    sse_vector:     89852 x2.98   3e-007 t=-39719.3711 o=-39719.3594
         GetPeak--[sse_vector]:     89852 (chosen)
------------------------------
                       f_sum--:    312656 x1.00        0 -- [ avg magnitude =   0.9727 (50)]
                       unroll4:    402960 x0.78 7.5e-008 t=4044.4708 o=4044.4705
                      hand_sse:    412668 x0.76 8.7e-008 t=4044.4702 o=4044.4705
                    sse_vector:    312636 x1.00        0 t=4044.4705 o=4044.4705
           f_sum--[sse_vector]:    312636 (chosen)
------------------------------
                    GetChiSq--:     59320 x1.00        0 -- [ avg magnitude =   0.9727 (50)]
                  hoisted+abs(:     61132 x0.97 3.7e-007 t=123.9554 o=123.9554
          GetChiSq--[original]:     59320 (chosen)
------------------------------
             IPP FFT SSE2(64K):   5605736 x1.00        0 -- [ avg magnitude =  30.3415 (50)]
   IPP FFT SSE2(64K)[original]:   5605736 (chosen)
------------------------------
Bench Time: 6.95 seconds

- [ pulse fold select ] -
                      Standard:   3224668 x1.00        0
                       FPU opt:   2903952 x1.11 1.7e-010
                       ben SSE:   2476848 x1.30        0
                        AK SSE:   2198280 x1.47 2.3e-007
                        BH SSE:   2229300 x1.45        0
                        AK SSE:   2198280 (chosen)
Test Time: 0.06 seconds


Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #125 on: 06 Jun 2007, 11:00:30 am »
though about this error

if we enter analyseFuncs the first to do is --->Allocate data array and work area arrays.

here are the importend statements:
int seti_analyze( ANALYSIS_STATE &state )
 ......
    NumDataPoints = state.npoints; //seti_britta: problem, npoints has no init value ?
struct ANALYSIS_STATE
    {
    sah_complex *data;
    sah_complex *savedWUData;   // Save the original WU data
    int         npoints;
    int         icfft;
    int         PoT_freq_bin;   // where we are in PoT analysis for this icfft

    // ... will be -1 if no PoT analysis in progress
    int         PoT_activity;
    int         doing_pulse;
    double      FLOP_counter;
    };
.......
    PowerSpectrum = ( float * ) MEM.calloc( "PowerSpectrum", NumDataPoints, sizeof(float) );
.......
we go now to MEM.calloc ---->
      void *calloc( const char *name, size_t size, size_t nitems, size_t alignment = MEM_ALIGN)
         {
         void *ptr = calloc_a( size, nitems, alignment );
         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
//         fprintf(stderr, "(%1.1fK) %s \n", size*nitems/1024.0, name);
         return ptr;
         };
-----------------------------------------------------
maybe nitems has no or a wrong value
-----------------------------------------------------
if NumDataPoints has no value, calloc fails and how you can see there is no opcode written  to prevent this, so we get a errormassage from the system like this ---->Can't set up shared mem: -1, Unhandled Exception Detected...
----------------------------------------------------------
it looks like this is the error, we will see if this will be confirm.......
 ;)

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #126 on: 06 Jun 2007, 12:42:22 pm »

it looks like this is the error, we will see if this will be confirm.......
 ;)
it is necessary to have a look at main.cpp and seti.cpp where wrote_header writes values into the structure ANALYSIS_STATE  ;)

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #127 on: 07 Jun 2007, 05:02:32 am »
the critical problem is in malloc_a.h
there are 2 variables undefined ---> nitems, alignment
-------------------------------------------------------------------------------
68      void *calloc( const char *name, size_t size, size_t nitems, size_t alignment = MEM_ALIGN)
69      {
70         void *ptr = calloc_a( size, nitems, alignment );
71         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
72//         fprintf(stderr, "(%1.1fK) %s \n", size*nitems/1024.0, name);
73         return ptr;
74         };

81      void __fastcall free( void * ptr )   { __OUR_FREE( ptr ); };

------------------------------------------------------------------------------------------------------------------
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(68) : warning C4002: Zu viele übergebene Parameter für das Makro 'calloc'
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(68) : error C2059: Syntaxfehler: 'Konstante'
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(81) : error C2059: Syntaxfehler: 'Konstante'
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(70) : error C2065: 'nitems': nichtdeklarierter Bezeichner
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(70) : error C2065: 'alignment': nichtdeklarierter Bezeichner
------------------------------------------------------------------------------------------------------------------------------------------------------------------
that´s the reason why the application crashes on the first call of calloc 
and this happen in main.cpp in the first lines --->

int main( int argc, char **argv )
    {
    int retval = 0, i;
    FORCE_FRAME_POINTER;
    run_stage = PREGRX;
    g_argc = argc;

    if ( !(g_argv = ( char ** ) calloc( argc + 2, sizeof(char *) )) )
        {
        exit( MALLOC_FAILED );
        }
----------------------------------------------------------------------------------------------------------------------------------
seti_britta ~heinz   ;)

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #128 on: 07 Jun 2007, 02:43:17 pm »
quote
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(68) : warning C4002: Zu viele übergebene Parameter für das Makro 'calloc'
--------------------------
calloc braucht genau 2 Parameter beim Aufruf
calloc(anzahl_der_elemente, groesse_der_elemente)
-------------------------------------------------------------------------------

next problem is the multideclaration of FORCE_FRAME_POINTER;
as you can see it is declared in s_util.h, line 133 and in seti.h line 144
and there are no cunstruct in the headerfiles to prevent this.
for instance:
#ifndef FORCE_FRAME_POINTER
#define FORCE_FRAME_POINTER
#endif
----------------------------------------------------------------
zur Erinnerung: ich habe es schon einmal in #36 gesagt --->
-----------------------------------------------------------------
Hauptsächliche Probleme im Projekt sind:
1. Migrationsprobleme -->siehe http://msdn2.microsoft.com/de-de/library/ms235289(VS.80).aspx
2. varalteter Deklarationsstil
3. Typkonvertierungen
4. Konvertierungen bei Parameterübernahme und Rückgabe in Funktionen.
5. Parameter in Makrodefinitionen
6. Benutzung nicht definierter Variablen
7. Multideclarationen (Mehrdeutigkeit)

um mal einige zu nennen

------------------------------------------------------------------
die Fehler in 4. und 5. sind oft schwierig zu finden, weil hier meist keine Typüberprüfung durch den Compiler durchgeführt wird. Dafür ist allein der Programmierer verantwortlich.
Das erklärt auch die Tatsache dass ein fehlerfrei compiliertes  Programm ,wie in unserem Fall geschehen, bei der Ausführung abstürzt .

seti_britta ~heinz  ;)

Offline Josef W. Segur

  • Janitor o' the Board
  • Knight who says 'Ni!'
  • *****
  • Posts: 3112
Re: optimized sources
« Reply #129 on: 07 Jun 2007, 06:41:39 pm »
...
next problem is the multideclaration of FORCE_FRAME_POINTER;
as you can see it is declared in s_util.h, line 133 and in seti.h line 144
and there are no cunstruct in the headerfiles to prevent this.
for instance:
#ifndef FORCE_FRAME_POINTER
#define FORCE_FRAME_POINTER
#endif
...

That seems to have crept into our sources before 2.0, I suggest changing to what the cvs sources now have; no define in seti.h and the following in s_util.h :

Code: [Select]
// The MS & intel compilers don't allow alloca in try/catch blocks
#ifndef FORCE_FRAME_POINTER
#if ( defined(HAVE_ALLOCA) || defined(_WIN32) ) && !( defined(__INTEL_COMPILER) || defined (_MSC_VER) )
#define FORCE_FRAME_POINTER alloca(16)
#else
#define FORCE_FRAME_POINTER (0)
#endif
#endif

Note: Crunch3r identified the error with Intel compiler, and the changes were made after that. But the 5.15 code from which ours has evolved was before.
                                                                                        Joe

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #130 on: 08 Jun 2007, 09:43:21 am »
Merci Joe, thank you for your comment.
I use the source seti_boinc_2k3_2.2B1-Ben-Joe.7z from 02.03.2007. Hoping that it is stiil actual.
regards seti_britta ~heinz

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #131 on: 08 Jun 2007, 01:56:09 pm »
@Simon
are there any changes in malloc_a.h since 2.2B source published ??
~heinz

Offline Simon

  • Ni!
  • Knight who says 'Ni!'
  • *****
  • Posts: 1045
    • Is it a bird? Is it a plane? No...its-the.net!
Re: optimized sources
« Reply #132 on: 08 Jun 2007, 05:17:58 pm »
I don't think so, no.

Regards,
Simon.

Offline _heinz

  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 2117
Re: optimized sources
« Reply #133 on: 12 Jun 2007, 08:41:02 am »
The difficulties to compile malloc_a.h
----------------------------------------------------
1. to find the eror we copy the first lines from main.cpp into a new project named seti_start. We set the necessary include paths and can compile now.
here ist the short program:
---------------------------------------------------------------------------------------------------------------------------------------------------------------
// start_seti.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
//
// Main program for command-line application.
// Usage: client [options]
//      -version show version info
//      -verbose print running status
//      -standalone
//      -bench
//      -show_benchmark

#include "stdafx.h"
#include "config.h"
    #include "boinc_win.h"
#include "diagnostics.h"
#include "util.h"
#include "s_util.h"
#include "boinc_api.h"
//#include "util.h"
//#include "s_util.h"
#include "analyze.h"
#include "analyzeFuncs.h"
#include "analyzePoT.h"
#include "worker.h"
#include "version.h"
#include "chirpfft.h"
#include "gaussfit.h"

#include "optimize.hpp"


// =======================================================================================
//    usage -
// =======================================================================================
void usage( void )
    {
    printf( "options:\n"
    #ifdef BOINC_APP_GRAPHICS
    " -nographics run without graphics\n"
    #endif
    " -version  show version info\n -verbose  print running status\n -standalone \n" );
    }

// =======================================================================================
//    print_error -
// =======================================================================================
void print_error( int e )
    {
    char    *p;
    p = error_string( e );
    fprintf( stderr, "%s\n", p );
    }

// =======================================================================================
//    print_version -
// =======================================================================================
void print_version( void )
    {
    printf( "SETI@home client.\nVersion: %d.%02d\n", gmajor_version, gminor_version );
    printf(
        "\nSETI@home is sponsored by individual donors around the world.\nIf you'd like to contribute to the project,\nplease visit the SETI@home web site at\nhttp://setiathome.ssl.berkeley.edu.\nThe project is also sponsored by the Planetary Society,\nthe University of California, Sun Microsystems, Paramount Pictures,\nFujifilm Computer Products, Informix, Engineering Design Team Inc,\nThe Santa Cruz Operation (SCO), Intel, Quantum Corporation,\nand the SETI Institute.\n\nSETI@home was developed by David Gedye (Founder),\nDavid Anderson (Director), Dan Werthimer (Chief Scientist),\nHiram Clawson, Jeff Cobb, Charlie Fenton,\nEric Heien, Eric Korpela, Matt Lebofsky,\nTetsuji 'Maverick' Rai and Rom Walton\n" );
    }

static int  g_argc;
static char **g_argv;
extern double           sigma_thresh;
extern double           f_PowerThresh;
extern double           f_PeakPowerThresh;
extern double           chi_sq_thresh;
bool                    nographics_flag;

int                     run_stage;
typedef seti_error      boinc_error;
extern APP_INIT_DATA    app_init_data;

//int _tmain(int argc, _TCHAR* argv[])
//{
int main( int argc, char **argv )
    {
    int retval = 0, i;
    FORCE_FRAME_POINTER;
    run_stage = PREGRX;
    g_argc = argc;

    if ( !(g_argv = ( char ** ) calloc( argc + 2, sizeof(char *) )) )
        {
        exit( MALLOC_FAILED );
        }

    setbuf( stdout, 0 );

    bool    standalone = false;
    #ifdef BOINC_APP_GRAPHICS
        nographics_flag = false;
    #else
        nographics_flag = true;
    #endif
   show_benchmark = false;
   g_argv[0] = argv[0];

    for ( i = 1; i < argc; i++ )
        {
        g_argv = argv;

        char    *p = argv;
        while ( *p == '-' ) p++;
        if ( !strncmp( p, "vers", 4 ) )
            {
            print_version();
            exit( 0 );
            }
        else if ( !strncmp( p, "verb", 4 ) )
            {
            verbose = 1;
            show_benchmark = true;
            }
        else if ( !strncmp( p, "st", 2 ) )
            {
            standalone = true;
            nographics_flag = true;
            }
        else if ( !strncmp( p, "no", 2 ) )
            {
            nographics_flag = true;
            }
        else if ( !strncmp( p, "bench", 5 ) )
            {
            show_benchmark = true;
            }
        else if ( !strncmp( p, "h", 1 ) )
            {
            usage();
            }
        }


   return 0;
}
------------------------------------------------------------------------------------------------------------



As you have seen bevore  there were 2 undefined variables, nitems, alignment. No problem, if we define it like this
      unsigned static int nitems, alignment;
We had todo this at the beginning in the class c_MEM. Here are the changed malloc_a.h
-------------------------------------------------------------------------------------------------------------------------

#if !defined( MALLOC_A_H )
#define MALLOC_A_H

#define MEM_ALIGN   64

#include "s_util.h"

void    * __fastcall malloc_a( size_t size, size_t alignment );
void    * __fastcall calloc_a( size_t size, size_t nitems, size_t alignment );
void    __fastcall free_a( void *palignedMem );

#if defined( USE_FFTWF )
   #include "fftw3.h"
   #define __OUR_MALLOC(size, align) fftwf_malloc( size )
   #define __OUR_FREE( ptr ) fftwf_free( ptr );
#elif defined( HAVE_MEMALIGN )
   #define __OUR_MALLOC(size, align) memalign( align, size )
   #define __OUR_FREE( ptr ) free( ptr );
#else
   #define __OUR_MALLOC(size, align) malloc_a( size, align )
   #define __OUR_FREE( ptr ) free_a( ptr );
#endif
class c_MEM {
   public:
      c_MEM() : used(0) {};
      ~c_MEM() {}   
      unsigned static int nitems, alignment; // seti_britta: new
      void *alloc( const char *name, size_t size, size_t alignment = MEM_ALIGN)
         {
         void *ptr = __OUR_MALLOC( size, alignment );
         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
//         fprintf(stderr, "(%1.1fK) %s \n", size/1024.0, name);
         return ptr;
         };
//seti_britta:syntaxfehler:´Konstante´ -->konstanten in fkt-Aufrufen sind unzulässig !
      void *calloc( const char *name, size_t size, size_t nitems, size_t alignment = MEM_ALIGN)
         {
         void *ptr = calloc_a( size, nitems, alignment );//error C2065: 'nitems': nichtdeklarierter Bezeichner, nitems, alignment
         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
//         fprintf(stderr, "(%1.1fK) %s \n", size*nitems/1024.0, name);
         return ptr;
         };
      void *callocQ( const char *name, size_t size, size_t nitems, size_t alignment = MEM_ALIGN)
         {
         void *ptr = calloc_a( size, nitems, alignment );
         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
         return ptr;
         };
      //seti_britta: malloc_a.h(83) : error C2059: Syntaxfehler: 'Konstante'
      void __fastcall free( void * ptr )   { __OUR_FREE( ptr ); };
//      void __fastcall free_a(void * ,1 );

      const char * __fastcall report( const char *name);
      int   used;
   };

// Create an actual structure to call based on
extern class c_MEM MEM;

#endif
--------------------------------------------------------------------------------------------------------------------------------------------------
If we compile now, we get:
Die Zwischen- und Ausgabedateien für das Projekt "start_seti" mit der Konfiguration "Debug|Win32" werden gelöscht.
Kompilieren...
stdafx.cpp
Kompilieren...
start_seti.cpp
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(68) : warning C4002: Zu viele übergebene Parameter für das Makro 'calloc'
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(68) : error C2059: Syntaxfehler: 'Konstante'
c:\i\sc\seti\seti_boinc_2k3_2.2b-ben-joe\client\malloc_a.h(83) : error C2059: Syntaxfehler: 'Konstante'
Das Buildprotokoll wurde unter "file://c:\I\VS2005\Projects\start_seti\start_seti\Debug\BuildLog.htm" gespeichert.
start_seti - 2 Fehler, 1 Warnung(en)
--------------------------------------------------------------------------------------------------------------------------------------------------------------
the problems are

68       void *calloc( const char *name, size_t size, size_t nitems, size_t alignment = MEM_ALIGN)
69         {
70         void *ptr = calloc_a( size, nitems, alignment );//error C2065: 'nitems': nichtdeklarierter Bezeichner, nitems, alignment
71         if ( ptr == NULL ) SETIERROR( MALLOC_FAILED, report( name ) );
72//         fprintf(stderr, "(%1.1fK) %s \n", size*nitems/1024.0, name);
73         return ptr;
74         };
----------------------------------------------------
83      void __fastcall free( void * ptr )   { __OUR_FREE( ptr ); };
----------------------------------------------------------------------------------------------------------------------------------------------
if we now goto 68 and look how calloc is declared we found in boinc_win.h --->
#define calloc(c, s)                          _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
if we now look how _calloc_dbg is declared we found a multideclaration(Mehrdeutigkeit) in two different files:
1. line 634 stdlib.h
_CRTIMP _CRT_JIT_INTRINSIC  _CRTNOALIAS _CRTRESTRICT __checkReturn __bcount_opt(_NumOfElements* _SizeOfElements)    void * __cdecl calloc(__in size_t _NumOfElements, __in size_t _SizeOfElements);

2. line 676 ff crtdbg.h
_CRTIMP __checkReturn __bcount_opt(_NumOfElements*_SizeOfElements) void * __cdecl _calloc_dbg(
        __in size_t _NumOfElements,
        __in size_t _SizeOfElements,
        __in int _BlockType,
        __in_z_opt const char * _Filename,
        __in int _LineNumber
        );
-----------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------
let´s now go to line 83 -->
83      void __fastcall free( void * ptr )   { __OUR_FREE( ptr ); };
we look now where  __OUR_FREE is declared and found in malloc_a.h line 53 --->
53   #define __OUR_FREE( ptr ) free_a( ptr );
we go now where free_a is declared and found in line 43 malloc_a.h --->
43 void    __fastcall free_a( void *palignedMem );
we had todo now set into the macro to resolve it........

The multideclaration is the problem, any suggestions to solve it are welcome
regards seti_britta ~heinz

Offline Josef W. Segur

  • Janitor o' the Board
  • Knight who says 'Ni!'
  • *****
  • Posts: 3112
Re: optimized sources
« Reply #134 on: 12 Jun 2007, 02:17:35 pm »
Overloaded functions are a feature of C and C++ so the compiler distinguishes between functions with the same name by the number and type of arguments. Name mangling distinguishes them in later parts of the compilation. There are fairly complex rules which allow for automatic conversion of types, and functions can actually be called with more arguments than shown in the declaration.

So, you are trying to do a DEBUG build and the overloaded calloc() definition in line 68 of malloc_a.h has the same number and type of arguments as the __calloc_dbg() which the boinc_win.h macro substitutes for calloc(). Conflict!

Crunch3r ran into the same thing when doing the Linux 2.2B builds so those sources have reverted all the MEM.calloc() etc. calls to calloc_a() etc. I think that's the best thing to do.
                                                                                      Joe

 

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?
Members
Total Members: 97
Latest: ToeBee
New This Month: 0
New This Week: 0
New Today: 0
Stats
Total Posts: 59559
Total Topics: 1672
Most Online Today: 652
Most Online Ever: 983
(20 Jan 2020, 03:17:55 pm)
Users Online
Members: 0
Guests: 645
Total: 645
Powered by EzPortal