Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
ParaEncode
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ParaEncode
Commits
2c2ad3f2
Commit
2c2ad3f2
authored
May 17, 2022
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
channel block based bug fix.
parent
f8c5b0e9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
8 deletions
+57
-8
channel.js
src/channel.js
+18
-6
Channel.spec.js
tests/Channel.spec.js
+38
-1
paraEncodeSpec.spec.js
tests/paraEncodeSpec.spec.js
+1
-1
No files found.
src/channel.js
View file @
2c2ad3f2
...
...
@@ -88,6 +88,7 @@ export class Channel {
#
writePhase
=
WRITE_PHASE
.
NO_STEP_WRITE
;
#
writePhaseEndPos
=
0
;
#
writePhaseWBlks
=
0
;
#
scheduler
=
undefined
;
...
...
@@ -292,10 +293,7 @@ export class Channel {
let
args
=
this
.
#
scheduleArgs
(
size
);
let
sch
=
this
.
#
scheduler
.
schedule
(
args
);
if
(
this
.
#
mode
==
CHANNEL_MODE
.
BLOCK
)
this
.
#
setWBlks
(
args
.
wBlks
);
return
sch
;
return
[
sch
,
args
];
}
dataView
()
{
...
...
@@ -416,7 +414,12 @@ export class Channel {
throw
new
ChnlStepConflictError
();
this
.
#
writePhase
=
WRITE_PHASE
.
WAIT_CALLER_WRITE
;
let
schedule
=
this
.
#
cpySchedule
(
size
);
let
info
=
this
.
#
cpySchedule
(
size
);
let
schedule
=
info
[
0
];
let
args
=
info
[
1
]
this
.
#
writePhaseWBlks
=
args
.
wBlks
;
let
plan_1
=
schedule
[
'first'
];
let
plan_2
=
schedule
[
'second'
];
...
...
@@ -446,6 +449,7 @@ export class Channel {
if
(
this
.
#
writePhase
!=
WRITE_PHASE
.
WAIT_CALLER_WRITE
)
throw
new
ChnlStepConflictError
();
this
.
#
writePointerUpdate
(
this
.
#
writePhaseEndPos
);
this
.
#
setWBlks
(
this
.
#
writePhaseWBlks
);
this
.
#
writePhase
=
WRITE_PHASE
.
NO_STEP_WRITE
;
}
...
...
@@ -454,6 +458,8 @@ export class Channel {
throw
new
Error
(
"Unable to push into Channel during Step Write"
);
}
console
.
log
(
this
.
#
getReadPointer
(),
this
.
#
getWritePointer
());
let
writePos
=
this
.
#
writePointerCache
;
this
.
#
readPointerCache
=
this
.
#
getReadPointer
();
...
...
@@ -465,7 +471,10 @@ export class Channel {
// Get a copy schedule, more details please read
// comment of #cpySchedule.
let
schedule
=
this
.
#
cpySchedule
(
data
.
byteLength
);
let
info
=
this
.
#
cpySchedule
(
data
.
byteLength
);
let
schedule
=
info
[
0
];
let
args
=
info
[
1
];
// Perfrom write schedule
let
srcPos
=
0
,
plan
;
...
...
@@ -476,12 +485,15 @@ export class Channel {
if
(
plan
.
size
==
0
)
continue
;
console
.
log
(
plan
);
let
d_
=
data
.
subarray
(
srcPos
,
srcPos
+
plan
.
size
);
this
.
#
buffer
.
set
(
d_
,
plan
.
pos
);
srcPos
+=
plan
.
size
;
writePos
=
plan
.
pos
+
plan
.
size
;
}
this
.
#
setWBlks
(
args
.
wBlks
);
// Caution: 'Write Pointer' must be updated after
// all datas are writed but not before or
// at intermediate of some writes otherwise
...
...
tests/Channel.spec.js
View file @
2c2ad3f2
import
{
sleep
}
from
'../src/utils.js'
;
import
{
sleep
,
waitCond
}
from
'../src/utils.js'
;
import
{
Observable
}
from
'rxjs'
;
import
{
Channel
}
from
'../src/channel.js'
;
...
...
@@ -450,4 +450,41 @@ describe("BLK-BASED Channel Spec", () => {
expect
(
chn
.
dataSize
()).
toBe
(
0
);
expect
(
areEqual
(
data
,
blkData
)).
toBe
(
true
);
});
});
fdescribe
(
"123"
,
()
=>
{
fit
(
"Data transfer to Webworker"
,
async
()
=>
{
const
rgbBlock
=
1920
*
1080
*
4
;
let
data
=
new
Uint8Array
([...
Array
(
rgbBlock
).
keys
()]);
let
ww
=
new
Worker
(
"../resources/tests/chnlWWHash.js"
);
await
sleep
(
3000
);
let
chnn
=
new
Channel
(
rgbBlock
*
3
)
chnn
.
enableBlockMode
(
rgbBlock
);
ww
.
postMessage
(
chnn
.
getShMem
());
await
sleep
(
3000
);
for
(
let
i
=
0
;
i
<
3000
;
++
i
)
{
while
(
true
)
{
let
buffers
=
chnn
.
writeStep1
(
rgbBlock
);
if
(
buffers
.
length
==
0
)
{
await
sleep
(
10
);
continue
;
}
buffers
[
0
].
set
(
data
,
0
);
chnn
.
writeStep2
();
break
;
}
// while (chnn.push(data) == false) {
// await sleep(10);
//}
}
console
.
log
(
"Done"
);
await
sleep
(
1000
);
},
3600000
)
});
tests/paraEncodeSpec.spec.js
View file @
2c2ad3f2
...
...
@@ -35,7 +35,7 @@ describe("ParaEncoder", () => {
},
3000000
);
});
f
describe
(
"ParaEncoder Blockbased"
,
()
=>
{
describe
(
"ParaEncoder Blockbased"
,
()
=>
{
beforeEach
(
async
()
=>
{
let
trNum
=
navigator
.
hardwareConcurrency
;
paraEnc
=
new
ParaEncoder
(
trNum
,
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment