进步。我设法修复了剩余的GF字段,包括QRCode和各种Aztec字段。使用RS Java代码进行验证。加载最新的ProCrypto1-1-1和ProCryptoTests-1-1-1将加载最新的RSFEC。
Installer ss
project: 'Cryptography';
install: 'ProCrypto-1-1-1';
install: 'ProCryptoTests-1-1-1';
install: 'CryptographyRSPlugin'.目前所有的方法都是插件化的,除了{#编码:#runEuclideanAlgorithm:.,#dividePoly.& @decode:twoS:}。当调用这些原语时,我会得到分段故障。调查..。
- 41541 tallies, 53540 msec.
((116473 - 53540) / 116473) asFloat * 100
54% SpeedUp
**Leaves**
Unpluganized
24.7% {13224ms} RSFECDecoderWithPlugin>>decode:twoS:
3.0% {1587ms} RSFECDecoderWithPlugin>>runEuclideanAlgorithmPoly:poly:rDegrees:
Pluganized
16.9% {9045ms} RSFECGenericGFPoly class>>newField:coefficients:
6.2% {3311ms} RSFECDecoderWithPlugin>>primFindErrorLocationsDegree:coefficients:fieldSize:expTable:logTable:
4.2% {2245ms} RSFECGenericGFPolyWithPlugin>>addOrSubtractPoly:
2.5% {1317ms} RSFECDecoderWithPlugin>>findErrorMagnitudes:errorLocations:
1.7% {887ms} RSFECGenericGFWithPlugin>>log:
1.1% {583ms} RSFECGenericGFPolyWithPlugin>>degree
Other
8.2% {4414ms} LargePositiveInteger(Integer)>>bitShift:
5.8% {3115ms} SecureHashAlgorithm>>finalHash
5.2% {2775ms} ByteArray class(Behavior)>>new:
5.1% {2705ms} LargePositiveInteger>>+
3.1% {1639ms} SecureHashAlgorithm>>hashInteger:seed:
2.4% {1260ms} SecureRandom>>nextRandom160
1.6% {833ms} SmallInteger(Magnitude)>>between:and:
1.5% {786ms} ByteArray>>unsignedLongAt:put:bigEndian:您可以阅读我的Squeak代码发布版实现中兴芦苇所罗门误差校正。有人建议我在这里提出一个问题。
到目前为止,加速率为56%。
注意:我得到了插件化的GF和GFPoly函数,除了#dividePoly:。一些解码方法起作用了。我正在更新这里的示例,使其成为: code。
现在,CryptographyRSPluginExtension-rww.7.mcz已经为FECDecoder、GFPoly和GaloisCodingLoop全部丢失了7个原语。构建并部署此RSPlugin,我将在GFFEC class>>#startUp:上放大映像。这是调试用的。这是名单。
GaloisCodingLoopOutputByteInputExpCodingLoopWithPlugin>>#primCheckSomeShardsMatrixRows: matrixRows
inputs: inputs
toCheck: toCheck
offset: offset
byteCount: byteCount
GaloisCodingLoopOutputByteInputExpCodingLoopWithPlugin>>#primCodeSomeShardsMatrixRows: matrixRows
inputs: inputs
outputs: outputs
offset: offset
byteCount: byteCount
GaloisCodingLoopOutputByteInputExpCodingLoopWithPlugin>>#primComputeValueMatrixRow: matrixRow
inputs: inputs
inputIndex: inputIndex
byteIndex: byteIndex
value: value
FECGFPolyWithPlugin>>#primInitializePolyFieldSize: fieldSize
coefficients: localCoefficients
FECGFPolyWithPlugin>>#primDividePolySelfCoefficients: coefficients
otherCoefficients: otherCoefficients
fieldSize: fieldSize
FECDecoderWithPlugin>>#primDecode: decoded
twoS: twoS
generatorBase: generatorBase
FECDecoderWithPlugin>>#primRunEuclideanAlgorithmPolyA: polyA
polyB: polyB
degrees: fieldSize下面是将所有内容加载到Squeak VMMaker映像中的VMMaker,构建在opensmalltalk-vm git克隆的图像目录中。13..
Installer ss
project: 'Cryptography';
install: 'ProCrypto-1-1-1';
install: 'ProCryptoTests-1-1-1';
install: 'CryptographyRSPlugin'.VM和项目链接:
2
3.
目前在DecoderWithPlugin>>#findErrorLocations失败:原始调用。奇怪的事,争论成零,看起来就像。那是怎么回事?这是调试日志/崩溃包。
我已经使用Squeak CCodeGenerator从RSFEC的GF插件代码中生成了C代码。现在是用于解码器的RSFECPlugin Smalltalk方法。
findErrorLocationsDegree: degree
coefficients: coefficients
count: count
fieldSize: fieldSize
result: result
"// This is a direct application of Chien's search"
<var: 'coefficients' type: #'unsigned char*'>
<var: 'result' type: #'unsigned char*'>
| numErrors e index |
numErrors := degree.
(numErrors = 1)
ifTrue: [^ result at: 0 put:(coefficients at: 0)].
e := 0.
index := 1.
[(index < fieldSize) & (e < numErrors)]
whileTrue: [
((self evaluateAt: index coefficients: coefficients count: count fieldSize: fieldSize) = 0)
ifTrue: [
result at: e put: (self inverse: index withSize: fieldSize).
e := e + 1].
index := index + 1].
(e = numErrors)
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
^ result这是翻译器的C代码。
/* // This is a direct application of Chien's search */
/* RSFECPlugin>>#findErrorLocationsDegree:
coefficients:
count:
fieldSize:
result: */
static unsigned char * findErrorLocationsDegreecoefficientscountfieldSizeresult(
sqInt degree,
unsigned char *coefficients,
sqInt count,
sqInt fieldSize,
unsigned char *result) {
sqInt e;
sqInt index;
sqInt numErrors;
numErrors = degree;
if (numErrors == 1) {
return result[0] = (coefficients[0]);
}
e = 0;
index = 1;
while ((index < fieldSize) && (e < numErrors)) {
if ((evaluateAtcoefficientscountfieldSize(index, coefficients, count, fieldSize)) == 0) {
result[e] = (inversewithSize(index, fieldSize));
e += 1;
}
index += 1;
}
if (!(e == numErrors)) {
return primitiveFailFor(PrimErrBadArgument);
}
return result;
}在我们等待的时候,也许你们都想看看Smalltalk代码3.,它被翻译成已发布的C代码.我应该包括正在讨论的源代码:
VM和项目链接:
2
primitiveMultiplyPolySelfCoefficientsOtherCoefficientsProductFieldSize
<export: true>
<var: 'selfCoefficients' type: 'unsigned char*' >
<var: 'otherCoefficients' type: 'unsigned char*' >
<var: 'product' type: 'unsigned char*' >
| otherCoefficients selfCoefficients product otherCount selfCount otherCoefficientsOop productOop selfCoefficientsOop fieldSize |
interpreterProxy methodArgumentCount = 4
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadNumArgs ].
selfCoefficientsOop := interpreterProxy stackObjectValue: 3.
otherCoefficientsOop := interpreterProxy stackObjectValue: 2.
productOop := interpreterProxy stackObjectValue: 1.
fieldSize := interpreterProxy stackIntegerValue: 0.
selfCount := interpreterProxy stSizeOf: selfCoefficientsOop.
otherCount := interpreterProxy stSizeOf: otherCoefficientsOop.
selfCoefficients := interpreterProxy firstIndexableField: selfCoefficientsOop.
otherCoefficients := interpreterProxy firstIndexableField: otherCoefficientsOop.
product := interpreterProxy firstIndexableField: productOop.
self
multiplyPolySelfCoefficients: selfCoefficients
selfCount: selfCount
otherCoefficients: otherCoefficients
otherCount: otherCount
product: product
fieldSize: fieldSize.
interpreterProxy methodReturnReceiver.这是用于翻译的Squeak代码,它执行实际的多项式乘法。注意:此方法的C代码被翻译成基本函数.
multiplyPolySelfCoefficients: selfCoefficients
selfCount: selfCount
otherCoefficients: otherCoefficients
otherCount: otherCount
product: product
fieldSize: fieldSize
<var: 'selfCoefficients' type: #'unsigned char*'>
<var: 'otherCoefficients' type: #'unsigned char*'>
<var: 'product' type: #'unsigned char*'>
| aCoeff aCoefficients aLength bCoefficients bLength |
aCoefficients := selfCoefficients.
aLength := selfCount.
bCoefficients := otherCoefficients.
bLength := otherCount.
0 to: (aLength - 1)
do: [:aIndex |
aCoeff := aCoefficients at: aIndex.
0 to: (bLength - 1)
do: [:bIndex |
product at: (aIndex + bIndex) put: ((self
addOrSubtract: (product at: (aIndex + bIndex))
by: (self multiply: aCoeff by: (bCoefficients at: bIndex) withSize: fieldSize))) ]].
^ product挺好的对吧?嘿,斯奎克。。。. '...* ^
我们运行在run (内存管理),Cog (JITting语言进程引擎)+ Sista (主动推进JITting)之上。Squeak VM的奥秘..。
希望热点将改变,插件已经有所帮助。他们做到了: 407%!我们会看看还能做什么.
我已经完成了插件工作。我现在有一个正在运行的插件。加速比为56%,所有热点再次发生变化。下面是仅来自RSFEC代码的分析结果,配置文件中没有RSErasure代码。新的热点是,使用RSFECPlugin,然后没有。
我实现了进一步的方法{#findErrorLocations:,#findErrorMagnitudes:errorLocations:,#decode:twoS:}。
剩余的潜在插件化与插件函数内部的复杂对象实例化有关。{#decode:twoS:,#runEuclideanAlgorithm:和#initializeField:系数:}。工作回报的最佳值是plugganize #initializeField:系数: 3.3秒(14%)
调用unplugganizedGFpoly/Decoder方法:
WITH GF & GFPOLY & DECODER PRIMITIVES
- 22194 tallies, 22648 msec.
(128683 / 22648 ) asFloat
**Leaves**
29.1% {6586ms} RSFECDecoderWithPlugin>>decode:twoS:
14.7% {3329ms} RSFECGenericGFPoly class>>newField:coefficients:
1.0% {237ms} RSFECDecoderWithPlugin>>runEuclideanAlgorithmPoly:poly:rDegrees:调用插件化GF/GFPoly/Decoder方法:
7.3% {1646ms} RSFECDecoderWithPlugin>>primFindErrorLocationsDegree:coefficients:result:fieldSize:
2.9% {654ms} RSFECDecoderWithPlugin>>findErrorMagnitudes:errorLocations:
1.4% {317ms} RSFECGenericGFWithPlugin>>log:和:
WITHOUT GF & GFPOLY PRIMITIVES - NO RSFEC PRIMITIVES
- 98352 tallies, 128683 msec.
**Leaves**
GF arithmetic
23.4% {30126ms} RSFECGenericGF>>exp:
13.4% {17229ms} RSFECGenericGF>>addOrSubtract:by:
11.9% {15251ms} RSFECGenericGF>>maskValue:
10.0% {12916ms} RSFECGenericGF>>log:
8.6% {11059ms} RSFECGenericGF>>normalizeIndex:
6.8% {8792ms} RSFECGenericGF>>multiply:by:
GFPoly arithmetic
2.7% {3529ms} RSFECGenericGFPoly>>evaluateAt:
2.1% {2715ms} RSFECGenericGFPoly>>addOrSubtractPoly:
2.0% {2578ms} RSFECGenericGFPoly>>multiplyByMonomialDegree:coefficient:小兔子。。。.‘^
发布于 2021-06-10 21:09:50
好吧,是的,让我们把这叫做答案。业绩提高568%。
我终于做出了改变。你知道吗,当你有两个图片,你在其中一个做工作,然后忘记,然后删除,并必须重新编码所有这些更改?一点儿没错。
尽管如此,我还是做了一些更改,并测试了如何在基本/计算方法中创建ByteArray:
#fecAddOrSubtractPolySelfCoefficients:selfCount:otherCoefficients:otherCount:.在我的例子中,我决定在计算方法中创建结果ByteArray,并将resultOop返回给# method return :的原语。这是原语,然后是计算方法。这似乎在我编译和测试它的时候起作用了。一个考虑因素是,如果我们处于一个原语中,并且调用另一个元素,就像在解码方法中一样,那么我必须记住#解释性array : resultOop再次访问数组(例如,作为参数传递给另一个计算方法)。这是最好的办法吗?
resultOop := self
fecAddOrSubtractPolySelfCoefficients: selfCoefficients
selfCount: selfCount
otherCoefficients: otherCoefficients
otherCount: otherCount.
^ interpreterProxy failed
ifTrue: [interpreterProxy primitiveFail]
ifFalse: [interpreterProxy methodReturnValue: resultOop].以及计算方法
resultOop := interpreterProxy
instantiateClass: interpreterProxy classByteArray
indexableSize: (selfCount max: otherCount).
result := interpreterProxy firstIndexableField: resultOop.
"COMPUTATIONS filling #result"
^ resultOophttps://codereview.stackexchange.com/questions/261315
复制相似问题