From e1259a6bb8e9e39f232230fece0146657743f079 Mon Sep 17 00:00:00 2001 From: NicJA Date: Fri, 3 Mar 2017 05:22:43 +0000 Subject: [PATCH] wip update. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@54028 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- test/exec/smp/main.c | 12 ++++++----- test/exec/smp/work.h | 4 ++-- test/exec/smp/worker.c | 54 ++++++++++++++++++++++++++++---------------------- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/test/exec/smp/main.c b/test/exec/smp/main.c index 9b75736f3f..8d87317b80 100644 --- a/test/exec/smp/main.c +++ b/test/exec/smp/main.c @@ -194,7 +194,7 @@ int main() GetBitMapAttr(displayWin->WScreen->RastPort.BitMap, BMA_DEPTH), BMF_DISPLAYABLE, displayWin->WScreen->RastPort.BitMap); - workMaster.smpm_WorkBuffer = AllocMem(workMaster.smpm_Width * workMaster.smpm_Height * 8, MEMF_ANY|MEMF_CLEAR); + workMaster.smpm_WorkBuffer = AllocMem(workMaster.smpm_Width * workMaster.smpm_Height * sizeof(ULONG), MEMF_ANY|MEMF_CLEAR); D( bug("[SMP-Test] %s: Target BitMap @ 0x%p\n", __func__, outputBMap); @@ -242,7 +242,7 @@ int main() outBMRastPort, 0, 0, workMaster.smpm_Width, workMaster.smpm_Height, - RECTFMT_GREY8); + RECTFMT_ARGB); if (complete) { @@ -270,9 +270,11 @@ int main() case IDCMP_REFRESHWINDOW: D(bug("[SMP-Test] %s: Displaying output BitMap (REFRESHWINDOW)\n", __func__);) + BeginRefresh(msg->IDCMPWindow); BltBitMapRastPort (outputBMap, 0, 0, - displayWin->RPort, displayWin->BorderLeft, displayWin->BorderTop, - width, height, 0xC0); + msg->IDCMPWindow->RPort, msg->IDCMPWindow->BorderLeft, msg->IDCMPWindow->BorderTop, + width, height, 0xC0); + EndRefresh(msg->IDCMPWindow, TRUE); break; } ReplyMsg((struct Message *)msg); @@ -295,7 +297,7 @@ int main() PutMsg(coreWorker->smpw_MsgPort, (struct Message *)workMsg); } } - FreeMem(workMaster.smpm_WorkBuffer, workMaster.smpm_Width * workMaster.smpm_Height * 8); + FreeMem(workMaster.smpm_WorkBuffer, workMaster.smpm_Width * workMaster.smpm_Height * sizeof(ULONG)); CloseWindow(displayWin); outBMRastPort->BitMap = NULL; FreeRastPort(outBMRastPort); diff --git a/test/exec/smp/work.h b/test/exec/smp/work.h index 077f44b2db..b011793d32 100644 --- a/test/exec/smp/work.h +++ b/test/exec/smp/work.h @@ -12,7 +12,7 @@ struct SMPMaster struct List smpm_Workers; struct Task *smpm_Master; struct MsgPort *smpm_MasterPort; - UBYTE *smpm_WorkBuffer; + ULONG *smpm_WorkBuffer; UWORD smpm_Width; UWORD smpm_Height; }; @@ -30,7 +30,7 @@ struct SMPWorkMessage { struct Message smpwm_Msg; IPTR smpwm_Type; - UBYTE *smpwm_Buffer; + ULONG *smpwm_Buffer; UWORD smpwm_Width; UWORD smpwm_Height; UWORD smpwm_Start; diff --git a/test/exec/smp/worker.c b/test/exec/smp/worker.c index 7cb2827316..2fd6ca86b0 100644 --- a/test/exec/smp/worker.c +++ b/test/exec/smp/worker.c @@ -30,14 +30,14 @@ typedef struct { struct WorkersWork { - int workMax; + ULONG workMax; complexno_t workTrajectories[]; }; -UQUAD calculateTrajectory(struct WorkersWork *workload, double r, double i) +ULONG calculateTrajectory(struct WorkersWork *workload, double r, double i) { double realNo, imaginaryNo, realNo2, imaginaryNo2; - int trajectory; + ULONG trajectory; /* Calculate trajectory */ realNo = 0; @@ -49,12 +49,12 @@ UQUAD calculateTrajectory(struct WorkersWork *workload, double r, double i) realNo2 = realNo * realNo; imaginaryNo2 = imaginaryNo * imaginaryNo; - if (realNo2 + imaginaryNo2 > 4.0L) + if (realNo2 + imaginaryNo2 > 2.0) return trajectory; /* Next */ - imaginaryNo = 2 * realNo * imaginaryNo + i; realNo = realNo2 - imaginaryNo2 + r; + imaginaryNo = 2 * realNo * imaginaryNo + i; /* Store */ workload->workTrajectories[trajectory].r = realNo; @@ -64,15 +64,16 @@ UQUAD calculateTrajectory(struct WorkersWork *workload, double r, double i) return 0; } -void processWork(struct WorkersWork *workload, UBYTE *workBuffer, UWORD workWidth, UWORD workHeight, UWORD workStart, UWORD workEnd) +void processWork(struct WorkersWork *workload, ULONG *workBuffer, UWORD workWidth, UWORD workHeight, UWORD workStart, UWORD workEnd) { - UQUAD trajectoryLength, pos; - double diff, x, y, y_base, diff_sr; - UWORD current; - int i; - int full_width = (int)workWidth; -// workMsg->smpwm_Height; + double xlo = -1.0349498063694267; + double ylo = -0.36302123503184713; + double xhi = -0.887179105732484; + double yhi = -0.21779830509554143; + ULONG trajectoryLength; + UWORD current; + UWORD x, y; DWORK( bug("[SMP-Test:Worker] %s: Buffer @ 0x%p\n", __func__, workBuffer); @@ -80,33 +81,38 @@ void processWork(struct WorkersWork *workload, UBYTE *workBuffer, UWORD workWidt bug("[SMP-Test:Worker] %s: start : %d, end %d\n", __func__, workStart, workEnd); ) - diff = 4.0L / (double)workWidth; - diff_sr = 4.0L / (double)workWidth; - - y_base = 2.0L - (diff / 2); - for (current = workStart; current < workEnd; current++) { + ULONG val; + /* Locate the point on the complex plane */ - x = ((double)(current % full_width)) * diff - 2.0L; - y = ((double)(current / full_width)) * diff - y_base; + x = (current % workWidth); + y = (current / workWidth); /* Calculate the points trajectory ... */ - trajectoryLength = calculateTrajectory(workload, x, y); + trajectoryLength = calculateTrajectory(workload, (double)(xlo + (xhi - xlo) * x / workWidth), (double)(ylo + (yhi - ylo) * y / workHeight)); +#if (0) /* Update the display if it escapes */ if (trajectoryLength > 0) { + UQUAD pos; + int i; + for(i = 0; i < trajectoryLength; i++) { - pos = ((UQUAD)((workload->workTrajectories[i].i + y_base) / diff_sr)) * workWidth + - ((UQUAD)((workload->workTrajectories[i].r + 2.0L) / diff_sr)); + pos = (workload->workTrajectories[i].i * workWidth) + workload->workTrajectories[i].r; if (pos > 0 && pos < (workWidth * workHeight)) { - __AROS_ATOMIC_INC_B(workBuffer[pos]); + val = (trajectoryLength / (workload->workMax/ 255)); + workBuffer[pos] = workBuffer[pos] + ((val << 16) | (val << 8) | val); } } } +#else + val = (trajectoryLength / (workload->workMax/ 255)); + workBuffer[current] = ((val << 16) | (val << 8) | val); +#endif } } @@ -147,7 +153,7 @@ void SMPTestWorker(struct ExecBase *SysBase) while (doWork) { UWORD workWidth, workHeight, workStart, workEnd; - UBYTE *workBuffer; + ULONG *workBuffer; IPTR workType; /* we are ready for work .. */ -- 2.11.4.GIT