Issue 15135 - std.parallelism taskPool.amap compilation error for array of tuple of tuple or tuple of struct results
Summary: std.parallelism taskPool.amap compilation error for array of tuple of tuple o...
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-01 20:33 UTC by Jay Norwood
Modified: 2024-12-01 16:25 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jay Norwood 2015-10-01 20:33:52 UTC
This generates the following compile error if I uncomment the taskPool.amap line.  The TR definition causes the amap error for either struct or Tuple definitions.

Ali Cehreli did some analysis in the thread:
http://forum.dlang.org/post/dtebpnktznzdusnontkn@forum.dlang.org


Severity	Code	Description	Project	File	Line
Error		Error: static assert  "Wrong buffer type."		C:\D\dmd2\src\phobos\std\parallelism.d	1668
Error		instantiated from here: amap!(MapResult!(getTerm, Result), Tuple!(TR, "L1_MISS", TR, "L1D_ACCESS")[])		d:\visd\dmapbug\dmapbug\main.d	40


import std.algorithm, std.parallelism, std.range;
import std.typecons;
import std.meta;
import std.stdio;

// define some input measurement sample tuples and output metric tuples

struct TR { long raw; double per_cyc;}
//alias TR = Tuple!(long, "raw", double, "per_cyc");
alias TI = Tuple!(long, "L1I_MISS",long, "L1D_MISS", long, "L1D_READ", long, "L1D_WRITE", long, "cycles" );
alias TO = Tuple!(TR, "L1_MISS", TR, "L1D_ACCESS");

// various metric definitions
// using Tuples with defined names for each member, and use the names here in the metrics.
TR met_l1_miss ( ref TI m){ TR rv;  rv.raw = m.L1I_MISS+m.L1D_MISS;  rv.per_cyc = cast(double)rv.raw/m.cycles; return rv; }
TR met_l1_access ( ref TI m){ TR rv;  rv.raw = m.L1D_READ+m.L1D_WRITE;  rv.per_cyc = cast(double)rv.raw/m.cycles; return rv; }

// a convenience to use all the metrics above as a list
alias Metrics = AliasSeq!(met_l1_miss, met_l1_access);

void main(string[] argv)
{
	auto samples = iota(100);
	auto meas = new TI[samples.length];
	auto results = new TO[samples.length];

	// Initialize some values for the measured samples
	foreach(i, ref m; meas){
		m.L1D_MISS= 100+i; m.L1I_MISS=100-i; 
		m.L1D_READ= 200+i; m.L1D_WRITE=200-i; 
		m.cycles= 10+i;
	}

    ref TI getTerm(int i)
    {
        return meas[i];
    }

	// compute the metric results for the above measured sample values in parallel
	//taskPool.amap!(Metrics)(std.algorithm.map!getTerm(samples),results);

	TR rv1 = met_l1_miss( meas[1]);
	TR rv2 = met_l1_access( meas[1]);

	writeln("measurements:", meas[1]);
	writeln("rv1:", rv1);
	writeln("rv2:", rv2);
	writeln("results:", results[1]);

}
Comment 1 dlangBugzillaToGithub 2024-12-01 16:25:11 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10143

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB