Thread Closed 
 
Thread Rating:
  • 24 Votes - 3.75 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[FIXED]HQ3x/4x ASM filters border
Author Message
spacy51 Offline
VBA-M Developer
*******

Posts: 451
Joined: Mar 2008
Reputation: 3
Post: #1
[FIXED]HQ3x/4x ASM filters border
HQ3x/4x ASM implementation produces wrong interpolation on the image's border. Look at the attached screenshot. It is obvious at the top of the "VIOLET CITY" text.
   


Hints to fix it:
This bug has already been fixed in the C version; look at hq_base.h / line 343 - 372.
The ASM version most likely only has something like skipLine instead of skipLinePlus and skipLineMinus, which is however necessary in order to work correctly.

This bug is most probably the cause why only the HQ3x/4x filters cause an exception with me new multi-threaded filter execution.
I get the following error message:
Quote:Unhandled exception at 0x00511ba9 in VisualBoyAdvance.exe: 0xC0000005: Access violation writing location 0x02c21000.
The debugger points me to hq4x_32.asm line 960.

The asm version of the HQ2x filter does not have this bug.

I would really appreciate if anyone knowledgeable of asm can try to figure a fix out for it. Until this bug is fixed, I can't really submit my multi-threading patch Sad
(This post was last modified: 01-22-2009 07:47 PM by Squall Leonhart.)
03-24-2008 04:42 AM
Visit this user's website Find all posts by this user
chrono Offline
VBA-M Contributor
*****

Posts: 32
Joined: Mar 2008
Reputation: 0
Post: #2
RE: HQ3x/4x ASM filters border
spacy51 Wrote:HQ3x/4x ASM implementation produces wrong interpolation on the image's border. Look at the attached screenshot. It is obvious at the top of the "VIOLET CITY" text.


Attached File(s)
.gz  hq-asm.diff.gz (Size: 351 bytes / Downloads: 30)
03-25-2008 01:28 PM
Find all posts by this user
mudlord Offline
not banned.
*****

Posts: 507
Joined: Feb 2009
Reputation: 5
Post: #3
RE: HQ3x/4x ASM filters border
Thanks for the patch. Smile
03-25-2008 02:09 PM
Visit this user's website Find all posts by this user
spacy51 Offline
VBA-M Developer
*******

Posts: 451
Joined: Mar 2008
Reputation: 3
Post: #4
RE: HQ3x/4x ASM filters border
Thank you so much for the patch.

It looks perfect now:    



Unfortunately, Multi-Threading still doesn't work with thw HQ3x/4x filters, which means there has to be another cause.
This means, there is still a faulty piece of code in the filter, which accesses memory outside of the source or destination bitmap. This causes access conflicts when the other memory area is currently in use by another CPU core.
A mutex on the whole image area is no option, because the whole thing wouldn't be faster than on a single core, moreover the current state may have unforseen side effects even on single cores.
03-25-2008 09:28 PM
Visit this user's website Find all posts by this user
mudlord Offline
not banned.
*****

Posts: 507
Joined: Feb 2009
Reputation: 5
Post: #5
RE: HQ3x/4x ASM filters border
Quote:Unfortunately, Multi-Threading still doesn't work with thw HQ3x/4x filters, which means there has to be another cause.
This means, there is still a faulty piece of code in the filter, which accesses memory outside of the source or destination bitmap. This causes access conflicts when the other memory area is currently in use by another CPU core.

Gotta love multithreading and thread-safety hey? Bricks

And its funny how I see on Ngemu that noobs see it as easy.....They should try it before they say such things....
03-25-2008 09:47 PM
Visit this user's website Find all posts by this user
chrono Offline
VBA-M Contributor
*****

Posts: 32
Joined: Mar 2008
Reputation: 0
Post: #6
RE: HQ3x/4x ASM filters border
spacy51 Wrote:Multi-Threading still doesn't work with thw HQ3x/4x filters, which means there has to be another cause.
ASM filters are not thread-safe Wink


Attached File(s)
.gz  hq4x_32-ts.asm.gz (Size: 7.25 KB / Downloads: 23)
03-26-2008 02:33 AM
Find all posts by this user
spacy51 Offline
VBA-M Developer
*******

Posts: 451
Joined: Mar 2008
Reputation: 3
Post: #7
RE: HQ3x/4x ASM filters border
chrono Wrote:
spacy51 Wrote:Multi-Threading still doesn't work with thw HQ3x/4x filters, which means there has to be another cause.
ASM filters are not thread-safe Wink


But the 2xSaI, Super 2xSaI and Super Eagle ASM filters work without changes.

You did a very great job on the hq4x_32 filter. It works perfectly now.

I get a speed increase from about 200% (1 core) to 250% (2 cores) now.


It looks like you had to change almost every line in the .asm file. Could you maybe provide me with some info on what was the problem with the code?

Would you be so kind to do the same magic on the other 3 versions? HQ3x_32 (has top priority)
HQ4x_16
HQ3x_16

I'll make sure you get your name into the about box.


EDIT:
Uploaded changes, SVN469
(This post was last modified: 03-26-2008 05:17 AM by spacy51.)
03-26-2008 05:10 AM
Visit this user's website Find all posts by this user
chrono Offline
VBA-M Contributor
*****

Posts: 32
Joined: Mar 2008
Reputation: 0
Post: #8
RE: HQ3x/4x ASM filters border
thread-safe filters: bilinear.cpp, hq3x_16.asm, hq3x_32.asm, hq4x_16.asm, hq4x_32.asm


Attached File(s)
.gz  ts-filters.tar.gz (Size: 26.29 KB / Downloads: 25)
(This post was last modified: 03-26-2008 12:09 PM by chrono.)
03-26-2008 09:44 AM
Find all posts by this user
Squall Leonhart Online
The Admin with the Gunblade
*******

Posts: 1,491
Joined: Mar 2008
Reputation: 16
Post: #9
RE: HQ3x/4x ASM filters border
which are faster, ASM or C filters?

secondly, can a 4xSaI filter be done in ASM?

03-26-2008 11:41 AM
Visit this user's website Find all posts by this user
spacy51 Offline
VBA-M Developer
*******

Posts: 451
Joined: Mar 2008
Reputation: 3
Post: #10
RE: HQ3x/4x ASM filters border
I comitted chrono's fixes and added an an option to set the maximum number of threads to create. The option is not yet exposed to the GUI, but can be changed in the ini. If the "maxCpuCores" option does not exist or is invalid, it will be auto-detected using the CPUID instruction.

Somehow my speed results vary, I probably have to add a mechanism to explicitly run each thread on an individual core instead of letting windows guess.
(This post was last modified: 04-29-2008 02:22 AM by spacy51.)
03-27-2008 02:23 AM
Visit this user's website Find all posts by this user
Thread Closed 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: