Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 394
    • Issues 394
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 24
    • Merge requests 24
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #1321
Closed
Open
Created May 27, 2010 by Carl Joslin@cajGuest

NEUTRAL != INITIAL

Bugzilla Link 714
Created on May 27, 2010 17:48
Resolution FIXED
Resolved on Jun 11, 2010 08:23
Version svn
OS All
Architecture All
Attachments fold.11.sac, fold.sac

Extended Description

Created an attachment (id=719)
Code that causes bug
Jing has located a bug that I am very concerned about as it seems so fundamental.
The problem is with:
  b = with{
        ([0,0] <= iv < [100,50])  :a[iv]+tof(iv[0]+iv[1]);
        ([0,50] <= iv < [100,100]):a[iv] *tof(iv[0]-iv[1]);
      }:fold( +, 0f);
With the sequential backend we get a result of:
250099
I have no reason to think this is wrong.
Now how about mt with one thread:
250099
still fine.
Now mt with two threads:
625198
that does not seem correct and if I run it again I get:
625198
so seems consistent
So lets look at more threads
3  1.0003e+06
4  1.3754e+06
5  1.7505e+06
Now it seems to have a pattern add a thread and increase the result by 375099.
If we look at -b11 we can see the problem:
  _hwlg_0 = with      /** FOLDABLE (all gen's const) **/
      /** REFERENCED: 1 (total num refs) **/
 {
        ([ 0, 0 ] <= iv=[_eat_37, _eat_36] < [ 100, 50 ])
        {
...
        } : _al_1166 ;
 } :
      fold( ScalarArith::+, _flat_5);
  b = with      /** FOLDABLE (all gen's const) **/
      /** REFERENCED: 1 (total num refs) **/
 {
        ([ 0, 50 ] <= iv__SSA0_1=[_eat_39, _eat_38] < [ 100, 100 ])
        {
...
        } : _pinl_447__flat_205 ;
 } :
      fold( ScalarArith::+, _hwlg_0);
If one looks at the generator of _hwlg_0, "handle_with_loop_generators" it even clams that it is doing it
 * This traversal transformes Multi-Generator With-Loops into sequences of                                                    
 * Single-Generator With-loops. To understand the basic principle, let us look                                                
 * at the three base cases:                                                                                                   
 * Expressions of the forms:                                                                                                  
 *                                                                                                                            
 *    with {                    with {                    with {                                                              
 *       (  ) : e1;            (  ) : e1;            (  ) : e1;                                                   
 *       (  ) : e2;            (  ) : e2;            (  ) : e2;                                                   
 *       (  ) : e3;            (  ) : e3;            (  ) : e3;                                                   
 *     } genarray( shp, def)     } modarray( a)            } fold( fun, neutr)                                                
 *                                                                                                                            
 * are semantically equivalent to                                                                                             
 *                                                                                                                            
 *     with {                    with {                    with {                                                             
 *       (  ) : e3;            (  ) : e3;            (  ) : e3;                                                   
 *     } modarray( tmp)          } modarray( tmp)          } fold( fun, tmp)                                                  
 *                                                                                                                            
 * provided the variable tmp is defined as                                                                                    
 *                                                                                                                            
 * tmp = with {                  tmp = with {              tmp = with {                                                       
 *         (  ) : e2;                (  ) : e2;            (  ) : e2;                                             
 *       } modarray( tmp2);            } modarray( tmp2);        } fold( fun, tmp2);                                          
 *                                                                                                                            
 * and tmp2 is defined as                                                                                                     
 *                                                                                                                            
 * tmp2 = with {                 tmp2 = with {             tmp2 = with {                                                      
 *          (  ) : e1;                (  ) : e1;            (  ) : e1;                                            
 *        } genarray( shp, def);        } modarray( a);           } fold( fun, neutr);  
So does this mean that hwlg is wrong with its long description of what it does and not being touched since 2007-11-13 or is the ast with its bad name and mutc and mt backends that do not expect this to happen.
One would expect the neutral element of the fold to have the following properties:
tutu = foldop( neutral, tutu);
tutu = foldop( tutu, neutral);
neutral = foldop( neutral, neutral);
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking