Changeset b9f383f for src


Ignore:
Timestamp:
Apr 27, 2018, 2:35:00 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
5527759
Parents:
de6319f
Message:

named threads in thread tests
fixed bounded buffer expect
added error check for waitfor with no parameters
added missing parameters to bounded buffer EXT

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    rde6319f rb9f383f  
    492492                        }
    493493
     494                        if(clause.target.arguments.empty()) {
     495                                SemanticError( stmt->location, "Waitfor clause must have at least one mutex parameter");
     496                        }
     497
    494498                        // Find all alternatives for all arguments in canonical form
    495499                        std::vector< AlternativeFinder > argAlternatives;
     
    556560                                                        auto param_end = function->parameters.end();
    557561
     562                                                        int n_mutex_arg = 0;
     563
    558564                                                        // For every arguments of its set, check if it matches one of the parameter
    559565                                                        // The order is important
     
    564570                                                                        // We ran out of parameters but still have arguments
    565571                                                                        // this function doesn't match
    566                                                                         SemanticError( function, "candidate function not viable: too many mutex arguments\n" );
     572                                                                        SemanticError( function, toString("candidate function not viable: too many mutex arguments, expected ", n_mutex_arg, "\n" ));
    567573                                                                }
    568574
     575                                                                n_mutex_arg++;
     576
    569577                                                                // Check if the argument matches the parameter type in the current scope
    570                                                                 if( ! unify( (*param)->get_type(), arg.expr->get_result(), resultEnv, resultNeed, resultHave, openVars, this->indexer ) ) {
     578                                                                if( ! unify( arg.expr->get_result(), (*param)->get_type(), resultEnv, resultNeed, resultHave, openVars, this->indexer ) ) {
    571579                                                                        // Type doesn't match
    572580                                                                        stringstream ss;
    573581                                                                        ss << "candidate function not viable: no known convertion from '";
     582                                                                        (*param)->get_type()->print( ss );
     583                                                                        ss << "' to '";
    574584                                                                        arg.expr->get_result()->print( ss );
    575                                                                         ss << "' to '";
    576                                                                         (*param)->get_type()->print( ss );
    577585                                                                        ss << "'\n";
    578586                                                                        SemanticError( function, ss.str() );
     
    588596                                                                // We ran out of arguments but still have parameters left
    589597                                                                // this function doesn't match
    590                                                                 SemanticError( function, "candidate function not viable: too few mutex arguments\n" );
     598                                                                SemanticError( function, toString("candidate function not viable: too few mutex arguments, expected ", n_mutex_arg, "\n" ));
    591599                                                        }
    592600
  • src/SynTree/Statement.cc

    rde6319f rb9f383f  
    453453void WaitForStmt::print( std::ostream &os, Indenter indent ) const {
    454454        os << "Waitfor Statement" << endl;
    455         os << indent << "... with block:" << endl << indent+1;
    456         // block->print( os, indent + 4 );
     455        indent += 1;
     456        for( auto & clause : clauses ) {
     457                os << indent << "target function :";
     458                if(clause.target.function) { clause.target.function->print(os, indent + 1); }
     459                os << endl << indent << "with arguments :" << endl;
     460                for( auto & thing : clause.target.arguments) {
     461                        if(thing) { thing->print(os, indent + 1); }
     462                }
     463                os << indent << " with statment :" << endl;
     464                if(clause.statement) { clause.statement->print(os, indent + 1); }
     465
     466                os << indent << " with condition :" << endl;
     467                if(clause.condition) { clause.condition->print(os, indent + 1); }
     468        }
     469
     470        os << indent << " timeout of :" << endl;
     471        if(timeout.time) { timeout.time->print(os, indent + 1); }
     472
     473        os << indent << " with statment :" << endl;
     474        if(timeout.statement) { timeout.statement->print(os, indent + 1); }
     475
     476        os << indent << " with condition :" << endl;
     477        if(timeout.condition) { timeout.condition->print(os, indent + 1); }
     478
     479
     480        os << indent << " else :" << endl;
     481        if(orelse.statement) { orelse.statement->print(os, indent + 1); }
     482
     483        os << indent << " with condition :" << endl;
     484        if(orelse.condition) { orelse.condition->print(os, indent + 1); }
    457485}
    458486
  • src/tests/concurrent/examples/.expect/boundedBufferEXT.txt

    rde6319f rb9f383f  
    1 concurrent/examples/boundedBufferEXT.c:39:1 error: No alternatives for function in call to waitfor
    2 /u/pabuhr/software/cfa-cc/include/cfa/bits/containers.h:170:1 error: candidate function not viable: no mutex parameters
    3 forall
    4   _6573_20_T: sized object type
    5   ... with assertions
    6     get_next: pointer to function
    7     ... with parameters
    8       reference to instance of type _6573_20_T (not function type)
    9     ... returning
    10       _retval_get_next: reference to pointer to instance of type _6573_20_T (not function type)
    11       ... with attributes:
    12         Attribute with name: unused
    13 
    14 
    15 
    16   lvalue function
    17 ... with parameters
    18   this: reference to instance of struct __queue with body 1
    19   ... with parameters
    20     instance of type _6573_20_T (not function type)
    21 
    22   it: pointer to pointer to instance of type _6573_20_T (not function type)
    23 ... returning
    24   _retval_remove: pointer to instance of type _6573_20_T (not function type)
    25   ... with attributes:
    26     Attribute with name: unused
    27 
    28 
    29 /usr/include/stdio.h:178:1 error: candidate function not viable: no mutex parameters
    30 lvalue function
    31 ... with parameters
    32   __filename: C pointer to const char
    33 ... returning
    34   _retval_remove: signed int
    35   ... with attributes:
    36     Attribute with name: unused
    37 
    38 
    39 concurrent/examples/boundedBufferEXT.c:47:1 error: No alternatives for function in call to waitfor
    40 concurrent/examples/boundedBufferEXT.c:37:1 error: candidate function not viable: too few mutex arguments
    41 forall
    42   _6578_20_T: sized object type
    43   ... with assertions
    44     ?=?: pointer to function
    45     ... with parameters
    46       reference to instance of type _6578_20_T (not function type)
    47       instance of type _6578_20_T (not function type)
    48     ... returning
    49       _retval__operator_assign: instance of type _6578_20_T (not function type)
    50       ... with attributes:
    51         Attribute with name: unused
    52 
    53 
    54     ?{}: pointer to function
    55     ... with parameters
    56       reference to instance of type _6578_20_T (not function type)
    57     ... returning nothing
    58 
    59     ?{}: pointer to function
    60     ... with parameters
    61       reference to instance of type _6578_20_T (not function type)
    62       instance of type _6578_20_T (not function type)
    63     ... returning nothing
    64 
    65     ^?{}: pointer to function
    66     ... with parameters
    67       reference to instance of type _6578_20_T (not function type)
    68     ... returning nothing
    69 
    70 
    71   lvalue function
    72 ... with parameters
    73   buffer: mutex reference to instance of struct Buffer with body 1
    74   ... with parameters
    75     instance of type _6578_20_T (not function type)
    76 
    77   elem: instance of type _6578_20_T (not function type)
    78 ... returning nothing
    79 
     1total:400000
  • src/tests/concurrent/examples/boundedBufferEXT.c

    rde6319f rb9f383f  
    1 // 
     1//
    22// The contents of this file are covered under the licence agreement in the
    33// file "LICENCE" distributed with Cforall.
    4 // 
    5 // boundedBufferEXT.c -- 
    6 // 
     4//
     5// boundedBufferEXT.c --
     6//
    77// Author           : Peter A. Buhr
    88// Created On       : Wed Apr 18 22:52:12 2018
     
    1010// Last Modified On : Fri Apr 20 22:25:14 2018
    1111// Update Count     : 6
    12 // 
     12//
    1313
    1414#include <stdlib>                                                                               // random
     
    3939forall( otype T )
    4040void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) {
    41         if ( count == BufferSize ) waitfor( remove );
     41        if ( count == BufferSize ) waitfor( remove, buffer );
    4242        elements[back] = elem;
    4343        back = ( back + 1 ) % BufferSize;
     
    4747forall( otype T )
    4848T remove( Buffer(T) & mutex buffer ) with( buffer ) {
    49         if ( count == 0 ) waitfor( insert );
     49        if ( count == 0 ) waitfor( insert, buffer );
    5050        T elem = elements[front];
    5151        front = ( front + 1 ) % BufferSize;
  • src/tests/concurrent/thread.c

    rde6319f rb9f383f  
    77thread Second { semaphore* lock; };
    88
    9 void ?{}( First & this, semaphore & lock ) { this.lock = &lock; }
    10 void ?{}( Second & this, semaphore & lock ) { this.lock = &lock; }
     9void ?{}( First  & this, semaphore & lock ) { ((thread&)this){"Thread 1"}; this.lock = &lock; }
     10void ?{}( Second & this, semaphore & lock ) { ((thread&)this){"Thread 2"}; this.lock = &lock; }
    1111
    1212void main(First& this) {
Note: See TracChangeset for help on using the changeset viewer.