Commit 2c2ad3f2 authored by Linshizhi's avatar Linshizhi

channel block based bug fix.

parent f8c5b0e9
......@@ -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
......
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)
});
......@@ -35,7 +35,7 @@ describe("ParaEncoder", () => {
}, 3000000);
});
fdescribe("ParaEncoder Blockbased", () => {
describe("ParaEncoder Blockbased", () => {
beforeEach(async () => {
let trNum = navigator.hardwareConcurrency;
paraEnc = new ParaEncoder(trNum, {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment