Hi Akihiro,

This is probably a bug in our implementation of first-class functions, it is 
not related to lifetime checking.

As a workaround, I got your program to compile when I removed the explicit type 
of the 'inspect' formal argument in createTaskAndYield, leaving it completely 
generic.

Vass

From: "Hayashi, Akihiro" <[email protected]>
Date: Monday, July 20, 2020 at 1:29 PM
To: "[email protected]" 
<[email protected]>
Cc: "Paul, Sri R" <[email protected]>, "Sarkar, Vivek" <[email protected]>
Subject: [Chapel-developers] Question about the lifetime checking for iterators

Dear all,

I'm now updating our GPUIterator module 
(https://github.com/ahayashi/chapel-gpu/tree/feature/1.22) to support Chapel 
1.22. I get a compilation error essentially saying that the compiler cannot 
resolve my iterator because one of the formal arguments does not match the 
actual argument.

Please take a look at the Chapel program attached (test.chpl), which is a 
simplified and standalone version of the GPUIterator, which reproduces my 
problem. In summary, “GPU()” iterator takes two arguments: 1) a distributed 
domain, and 2) a variable referring to a Chapel function (inspect() in this 
case). Inside the GPU iterator, it further calls “createTaskAndYield()” 
iterator that takes the same arguments. The problem is, the compiler complains 
that "createTaskAndYield()” is not resolved because the third argument does not 
match (the variable referring to the Chapel function, borrowed vs. shared).

Note: In this particular example, it does not make sense to have 
“createTaskAndYield”. However, in the actual GPUIterator implementation, 
“createTaskAndYield” contains common operations across multiple versions of the 
iterators (e.g., leader-follower, and standalone).

Here are detailed steps to reproduce this problem:

$ chpl --version
chpl version 1.22.0
Copyright 2020 Hewlett Packard Enterprise Development LP
Copyright 2004-2019 Cray Inc.
(See LICENSE file for more details)
$ chpl --fast test.chpl
warning: --specialize was set, but CHPL_TARGET_CPU is 'unknown'. If you want 
any specialization to occur please set CHPL_TARGET_CPU to a proper value.
test.chpl:16: In iterator 'GPU':
test.chpl:28: error: unresolved call 'createTaskAndYield(iterKind, 
range(int(64),bounded,false), borrowed chpl__fcf_type_int64_t_void)'
test.chpl:6: note: this candidate did not match: createTaskAndYield(param tag: 
iterKind, r: range(?), inspect: func(int, void))
test.chpl:28: note: because call actual argument #3 with type borrowed 
chpl__fcf_type_int64_t_void
test.chpl:8: note: is passed to formal 'inspect: shared 
chpl__fcf_type_int64_t_void'
test.chpl:46: Iterator 'GPU' instantiated as: GPU(param tag: iterKind = 
iterKind.standalone, D: BlockDom(1,int(64),false,unmanaged DefaultDist))

To be honest, I’m still learning the lifetime checking feature, but please let 
me know if you have any suggestions! Also, please let me know if you need more 
information.

Best regards,

Akihiro
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to