www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12446] New: std.parallelism.amap prefer iteration to indexing

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12446

           Summary: std.parallelism.amap prefer iteration to indexing
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: safety0ff.bugz gmail.com
        ReportedBy: safety0ff.bugz gmail.com


--- Comment #0 from safety0ff.bugz <safety0ff.bugz gmail.com> 2014-03-23
13:36:07 PDT ---
Currently std.parallelism.amap uses the random access range primitives instead
of the input range primitives to traverse the per-thread slices.

This matters when random access is more expensive than iteration.

Iteration, if properly implemented, should always at least as fast as indexing.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 23 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12446



--- Comment #1 from safety0ff.bugz <safety0ff.bugz gmail.com> 2014-03-23
13:54:09 PDT ---
(In reply to comment #0)
 This matters when random access is more expensive than iteration.
 
 Iteration, if properly implemented, should always at least as fast as indexing.

It occurred to me that the cost of slicing a range could be disproportionate to indexing. Are there any use cases where this is true? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12446


safety0ff.bugz <safety0ff.bugz gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from safety0ff.bugz <safety0ff.bugz gmail.com> 2014-03-23
14:37:56 PDT ---
https://github.com/D-Programming-Language/phobos/pull/2042

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 23 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12446


Andrei Alexandrescu <andrei erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei erdani.com


--- Comment #3 from Andrei Alexandrescu <andrei erdani.com> 2014-03-23 14:54:54
PDT ---
I think the differences should be negligible among the two approaches.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 23 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12446



--- Comment #4 from Andrei Alexandrescu <andrei erdani.com> 2014-03-23 14:55:56
PDT ---
... But there's always a way to test by measuring :o). Try it on a few typical
ranges. ("Typical" == cost of random access, if offered, shouldn't be onerous.)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 23 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12446



--- Comment #5 from safety0ff.bugz <safety0ff.bugz gmail.com> 2014-03-23
15:26:51 PDT ---
(In reply to comment #4)
 ... But there's always a way to test by measuring :o). Try it on a few typical
 ranges. ("Typical" == cost of random access, if offered, shouldn't be onerous.)

It's not typical array-like random access ranges that will benefit, it's atypical ones where iteration is simple but indexing is non-trivial. For example, my "triangular" random access range which returns the tuples: [0, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3] Iteration is simple, but indexing involves solving a quadratic + some other operations. Even though one might not call this "onerous," there is still enough relative difference for it to be noticeable. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12446



--- Comment #6 from github-bugzilla puremagic.com 2014-03-23 16:00:39 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/fc3cda0beb95d5164af5767c9f8134359968d294
Fix issue 12446 - std.parallelism.amap: prefer iteration to indexing

https://github.com/D-Programming-Language/phobos/commit/35617d87b30a3bf17d3dc50bf41bac4c4627c12f
Merge pull request #2042 from Safety0ff/fix12446

Fix issue 12446 - std.parallelism.amap: prefer iteration to indexing

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 23 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12446


safety0ff.bugz <safety0ff.bugz gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 23 2014