Hi,

I am currently trying to add a simple fallback in case the atomic statement
cannot be executed via HTM, however it looks like I need another push in
the right direction. What I have in mind for the generated code is
something like

if (CHPL_TSX_START()) {
  <atomic statement goes here>
  CHPL_TSX_END();
} else {
  CHPL_TSX_FALLBACK_START();
  <atomic statement goes here as well>
  CHPL_TSX_FALLBACK_END();
}

. My current compiler code is as follows, but it generates an internal
error (which is not surprising, as I hardly found any documentation).
Again, any pointers are welcome.

  BlockStmt* transaction = buildChapelStmt(new BlockStmt(stmt));
  BlockStmt* fallback    = transaction->copy();

  transaction->insertAtTail(new CallExpr("CHPL_TSX_STOP"));

  fallback->insertAtHead(new CallExpr("CHPL_TSX_FALLBACK_START"));
  fallback->insertAtHead(new CallExpr("CHPL_TSX_FALLBACK_STOP"));

  FnSymbol* ifFn = buildIfExpr(new CallExpr("CHPL_TSX_START"),
                                 transaction,
                                 fallback);

  return buildChapelStmt (new DefExpr(ifFn));


-Jens


On Fri, Mar 28, 2014 at 8:48 PM, Vassily Litvinov <[email protected]> wrote:

> Jens,
>
> To both your follow-up questions below - yes, your modifications of Brad's
> suggestions should be fine.
>
> Vass
>
>
> On 03/28/14 09:53, Jens Breitbart wrote:
>
>> Hi Brad,
>>
>> thanks. I think I modified the compiler, so I can insert my own code at
>> the
>> beginning/end of atomic statements. Just to be sure:
>>
>> On Tue, Mar 25, 2014 at 2:37 PM, Brad Chamberlain <[email protected]> wrote:
>>
>>    Hi Jens --
>>>
>>>   Without knowing much about the TSX interface, here's a very high-level
>>> potential sketch:
>>>
>>>   * write some C macros that wrap the start/end transaction instructions
>>> and look like function calls syntactically.
>>>       e.g.:
>>>         #define CHPL_TSX_START (<whatever magic starts the transaction
>>> via
>>> C>)
>>>         #define CHPL_TSX_STOP(<whatever magic stops the transaction via
>>> C>)
>>>
>>>
>> It wasn't working with macros, so I used static inline functions. Should I
>> expect any trouble or is this fine?
>>
>>
>>  * in the parser, insert "calls" to these external routines as the first
>>> and last statements of the block created when parsing an atomic block (in
>>> buildAtomicStmt()).
>>>
>>>       e.g.:
>>>         STMT* atomicBlock = new BlockStmt(stmt);
>>>         atomicBlock->insertAtHead(new CallExpr("CHPL_TSX_START"));
>>>         atomicBlock->insertAtTail(new CallExpr("CHPL_TSX_STOP"));
>>>
>>>
>> I used BlockStmt* instead of STMT*, but I guess that is fine?
>>
>>    BlockStmt* atomicBlock = buildChapelStmt(new BlockStmt(stmt));
>>
>>    atomicBlock->insertAtHead(new CallExpr("CHPL_TSX_START"));
>>
>>    atomicBlock->insertAtTail(new CallExpr("CHPL_TSX_STOP"));
>>
>>
>> - Jens
>>
>>
>>
>> ------------------------------------------------------------
>> ------------------
>>
>>
>>
>> _______________________________________________
>> Chapel-developers mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/chapel-developers
>>
>>
------------------------------------------------------------------------------
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to