原型设计返回了一个教堂内部错误:
虽然此特定设置的目的既无关紧要也不相关,
但编译器完成了以下调试通知,
对此,任何关于避免冲突语法的建议将不胜感激:
<TiO>-IDE-Debug::____________________________________________________
.code.tio.chpl:77: internal error: IMP0586 chpl Version 1.16.0 pre-release (-999)
Note: This source location is a guess.
Internal errors indicate a bug in the Chapel compiler ("It's us, not you"),
and we're sorry for the hassle. We would appreciate your reporting this bug --
please see http://chapel.cray.com/bugs.html for instructions. In the meantime,
the filename + line number above may be useful in working around the issue.
(编译器团队显然会对观察到的情况的内部处理有一些额外的兴趣和担忧,这不是本文的主要意图或主题)
代码,直播@ <TiO>-IDE::
/* ---------------------------------------SETUP-SECTION-UNDER-TEST--*/ use Time;
/* ---------------------------------------SETUP-SECTION-UNDER-TEST--*/ var aStopWATCH_RND_GEN: Timer;
/* ---------------------------------------SETUP-SECTION-UNDER-TEST--*/ var aStopWATCH_LIN_ALG: Timer;
/* ---------------------------------------SETUP-SECTION-UNDER-TEST--*/ var aStopWATCH_MAT_REC: Timer;
/* ---------------------------------------SETUP-SECTION-UNDER-TEST--*/ var aStopWATCH_ARR_REC: Timer;
config const n_power = 5;
config const L_size = 1000;
const indices = 1..L_size;
const aDomain = {indices, indices};
var A: [aDomain] real(64); // real(32); // may've shown some byte-word alignment artifacts
var B: [aDomain] real(64); // real(32); // may've shown some byte-word alignment artifacts
const dtype = "-real(64)";
var S: [aDomain] real(64); // real(32); // OK: must've been set real(64) to avoid /LinearAlgebra.chpl:535: error: type mismatch in assignment from real(64) to real(32)
/* -----------------------------------------------------------------*/ use Random;
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_RND_GEN.start();
Random.fillRandom( A );
Random.fillRandom( B );
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_RND_GEN.stop();
/*
============================================ */
proc arrMUL( arrA: [?DA] real(64),
arrB: [?DB] real(64)
) { /*
<Brad> If the domain/size of the array being returned cannot be described directly in the function prototype,
I believe your best bet at present is to omit any description of the return type and lean on Chapel's type inference machinery
to determine that you're returning an array
>>> https://stackoverflow.com/a/39420337/3666197
*/
var arrC: [aDomain] real(64);
/*
<TiO>-IDE-Debug::____________________________________________________
.code.tio.chpl:77: internal error: IMP0586 chpl Version 1.16.0 pre-release (-999)
Note: This source location is a guess.
Internal errors indicate a bug in the Chapel compiler ("It's us, not you"),
and we're sorry for the hassle. We would appreciate your reporting this bug --
please see http://chapel.cray.com/bugs.html for instructions. In the meantime,
the filename + line number above may be useful in working around the issue.
*/
/* var arrC: [{1..arrA.dim( 1 ).length(), // ..#arrA.dim( 1 ),
1..arrB.dim( 2 ).length() // ..#arrB.dim( 2 )
}
] real(64);
<TiO>-IDE-Debug::____________________________________________________
.code.tio.chpl:49: error: unresolved call '[domain(2,int(64),false)] real(64).dim(1)'
$CHPL_HOME/modules/internal/ChapelArray.chpl:1215: note: candidates are: _domain.dim(d: int)
$CHPL_HOME/modules/internal/ChapelArray.chpl:1218: note: _domain.dim(param d: int)
*/
// forall (row, col) in arrC.domain { // [ROW:77] reports: internal error: IMP0586 chpl Version 1.16.0 pre-release (-999)
forall (row, col) in aDomain { // [ROW:78] reports: internal error: IMP0586 chpl Version 1.16.0 pre-release (-999)
for i in arrA.dim( 2 ) do
arrC[row, col] += arrA[row, i]
* arrB[ i, col];
}
return arrC;
}
proc arr_REC_POW( arrM: [?D] real(64),
n: int(64) // int(32) failed:
// <- config const n_power = 5 // .code.tio.chpl:64: error: unresolved call 'arr_REC_POW([domain(2,int(64),false)] real(64), int(64))'
): [ D] real(64) { /*
<Brad> If the domain/size of the array being returned cannot be described directly in the function prototype,
I believe your best bet at present is to omit any description of the return type and lean on Chapel's type inference machinery
to determine that you're returning an array
>>> https://stackoverflow.com/a/39420337/3666197
<TiO>-IDE-Debug::____________________________________________________
.code.tio.chpl:56: error: unable to resolve return type of function 'arr_REC_POW'
.code.tio.chpl:56: In function 'arr_REC_POW':
.code.tio.chpl:61: error: called recursively at this point
// The ? operator is called the query operator, and is used to take
// undetermined values like tuple or array sizes and generic types.
// For example, taking arrays as parameters. The query operator is used to
// determine the domain of A. This is uesful for defining the return type,
// though it's not required.
// (c) 2017 Ian J. Bertolacci, Ben Harshbarger
// Originally contributed by Ian J. Bertolacci, and updated by 8 contributor(s).
>>> https://learnxinyminutes.com/docs/chapel/>
*/
if n < 1 then return arrM;
else return arrMUL( arrM, arr_REC_POW( arrM, n - 1 ) );
}
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_ARR_REC.start();
forall (row, col) in S.domain {
S[row, col] = arr_REC_POW( A, n_power )[row,col]
+ arr_REC_POW( B, n_power )[row,col];
}
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_ARR_REC.start();
/*
============================================ */
减少<TiO>-IDE
(可惜没有代码折叠生产力,就像在其他 IDE 环境中一样。同意 Ben 的观点,根据个人喜好,experiments-under-review 自文档布局可能更具可读性)
仍然
chpl:30: internal error: IMP0586 chpl Version 1.16.0 pre-release (-999)
chpl:30:
存在:
forall (row, col) in aDomain {
>>> aClickThrough -with-an-updated-code,没有语法警告但 (-999) @<TiO>-IDE
use Time;
var aStopWATCH_RND_GEN: Time.Timer;
var aStopWATCH_LIN_ALG: Time.Timer;
var aStopWATCH_MAT_REC: Time.Timer;
var aStopWATCH_ARR_REC: Time.Timer;
config const n_power = 5;
config const L_size = 1000;
const indices = 1..L_size;
const aDomain = {indices, indices};
var A: [aDomain] real(64);
var B: [aDomain] real(64);
const dtype = "-real(64)";
var S: [aDomain] real(64);
use Random;
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_RND_GEN.start();
Random.fillRandom( A );
Random.fillRandom( B );
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_RND_GEN.stop();
proc arrMUL( arrA: [?DA] real(64),
arrB: [?DB] real(64)
) {
var arrC: [aDomain] real(64);
forall (row, col) in aDomain {
arrC[row, col] = 0;
for i in arrA.dim( 2 ) do
arrC[row, col] += arrA[row, i]
* arrB[ i, col];
}
return arrC;
}
proc arr_REC_POW( arrM: [?D] real(64),
n: int(64)
): [ D] real(64) {
if n < 1 then return arrM;
else return arrMUL( arrM, arr_REC_POW( arrM, n - 1 ) );
}
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_ARR_REC.start();
forall (row, col) in S.domain {
S[row, col] = arr_REC_POW( A, n_power )[row,col]
+ arr_REC_POW( B, n_power )[row,col];
}
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_ARR_REC.start();
use LinearAlgebra;
var mA = LinearAlgebra.Matrix( A );
var mB = LinearAlgebra.Matrix( B );
var mS = LinearAlgebra.Matrix( S );
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_LIN_ALG.start();
mS = LinearAlgebra.matPlus( LinearAlgebra.matPow( mA, n_power ),
LinearAlgebra.matPow( mB, n_power )
);
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_LIN_ALG.stop();
proc mat_REC_POW( matM: [] real(64),
n: int(64)
) {
if n < 1 then return matM;
else return LinearAlgebra.dot( matM, mat_REC_POW( matM, n - 1 ) );
}
/* -----------------------------------------------re-fill-m?[,]-----*/
Random.fillRandom( A ); mA = Matrix( A ); // re-fill mA[,]
Random.fillRandom( B ); mB = Matrix( B ); // re-fill mB[,]
/* -----------------------------------------------re-fill-m?[,]-----*/
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_MAT_REC.start();
forall (row, col) in mS.domain {
mS[row, col] = mat_REC_POW( mA, n_power )[row,col]
+ mat_REC_POW( mB, n_power )[row,col];
}
/* ---------------------------------------------SECTION-UNDER-TEST--*/ aStopWATCH_MAT_REC.start();
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||| PERF--*/
writeln( ".fillRandom() took", aStopWATCH_RND_GEN.elapsed( Time.TimeUnits.microseconds ), " [us] for A[,], B[,] having ", 2 * ( L_size * L_size ), dtype, " elements in total." );
writeln(
"\n <SECTION-UNDER-TEST> took ", aStopWATCH_LIN_ALG.elapsed( Time.TimeUnits.microseconds ), " [us] in [LIN_ALG] mode ( A^n + B^b ) for [", L_size, ",", L_size, "] on <TiO>-IDE",
"\n <SECTION-UNDER-TEST> took ", aStopWATCH_MAT_REC.elapsed( Time.TimeUnits.microseconds ), " [us] in [MAT_REC] mode ( A^n + B^b ) for [", L_size, ",", L_size, "] on <TiO>-IDE",
"\n <SECTION-UNDER-TEST> took ", aStopWATCH_ARR_REC.elapsed( Time.TimeUnits.microseconds ), " [us] in [ARR_REC] mode ( A^n + B^b ) for [", L_size, ",", L_size, "] on <TiO>-IDE"
);
/* ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| INF--*/
writeln( "<TiO>-IDE-LocaleSpace is: ", LocaleSpace, " massive. Code is executing [here], being Locale ", here.id );
for i in LocaleSpace do
writeln( " Locale #", i, "'s ID is: ", Locales[i].id );