Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 24th February 2017, 01:50   #42  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
I just saw this: MONO supports SIMD instructions on both x86 and x64.
http://www.mono-project.com/news/201...meric-vectors/

but then it adds the MONO dependency. Not ideal, but it's an option.
MysteryX is offline   Reply With Quote
Old 1st March 2017, 02:00   #43  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Mono? What for? Let's start from the very begging, 'cause maybe I didn't get this right. (I mean, maybe I didn't understand what you are trying to do/achieve). If you write and compile filters using C and C++ you have access to SIMD, but the problem is that you need to know at compile time which instructions are available on your target machine. You need to be certain that the instructions in your binary are available on the target processor, but this is where a managed language’s JIT compiler is well placed. C# (thanks to the .NET Framework) code is compiled to an intermediate language called "Common Intermediate Language" (CIL, aka Microsoft Intermediate Language, MSIL), which is deployed to the target machine. When a program written in C# is loaded, the local .NET JIT compiler compiles the CIL to native code. The advantage is that the JIT compiler knows exactly what type of CPU the target machine has and so it can make full use of all instruction sets available to it. Besides, the application’s performance will improve in the future without ever being rebuilt and re-deployed. When future processors with larger SIMD registers become available JIT will be able to make full use them. The simplest and recommended way to use SIMD is via the classes and static methods in the System.Numerics namespace and you need at least version 4.1.0.0 of the System.Numerics and System.Numerics.Vectors assemblies. Anyway, let's stop talking about programs now. In this topic we are talking about avisynth filters that are going to run via a sort of "compatibility layer" which will make C# codes available in C++, like a "wrapper" - as you said before - which is the AVS filternet, so performance-wise it will be slower than native C++ filters, no matter what. So, the question is: what are you trying to do/achieve with SIMD? (I mean, this is not a critic at all, I'm just trying to understand, 'cause I love C#).

Last edited by FranceBB; 1st March 2017 at 02:08.
FranceBB is offline   Reply With Quote
Old 1st March 2017, 03:31   #44  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
No, you don't need to know which instruction sets are available at compile time with C/C++, basically you compile everything (even tho some might not be supported on your target machine) you have and use the cpuid instruction and detect the available best instruction set on the target machine at runtime and call the version of functions that were implemented with the detected best available instruction set dynamically.
feisty2 is offline   Reply With Quote
Old 1st March 2017, 16:15   #45  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
I'm still exploring what can be done with C#, because I'm a C# programmer and have no interest in learning assembly.

For a utility filter like MP_Pipeline, C# could do an excellent job -- and pass the video clips as input and output instead of ignoring the input.

If SIMD instructions become available, then it would also become possible to do video processing filters. It may still be a bit slower than C++, but on the plus side, the development time would be much shorter, and the maintenance would be much easier. We have a whole bunch of C++ plugins that are old and have never been maintained/updated, although many of the most useful ones are being upgraded for Avisynth+ x64.

This is not about whether C# or C++ is best. This discussion is simply about what can be done with C# and Avisynth.


The .NET Framework now has SIMD support, but only for x64. Avisynth filters need to work both with x86 and x64. MONO apparently does that, but I wouldn't want to create that dependency for users.
MysteryX is offline   Reply With Quote
Old 1st March 2017, 17:27   #46  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
Quote:
Originally Posted by MysteryX View Post
I'm still exploring what can be done with C#, because I'm a C# programmer and have no interest in learning assembly.
no assembly required, include this header file in your project and it does all the dirty work for you automatically, also extremely easy to use

Code:
//C++ 14
auto CPU = CPUFeatures{}; 
//yep, like the "var" feature in C#, you don't need to manually specify the variable types anymore in modern C++
//it's actually ok to just program in modern C++ like how you program in Python
//you don't have to care about types (auto and decltype), manual garbage collection (replaced by smart pointers) and tons of ugly shit inherited from C
if (CPU.sse2)
   blah
else if (CPU.avx)
   blah
else if (CPU.blah)
   blah
else
   blah
Quote:
Originally Posted by MysteryX View Post
This is not about whether C# or C++ is best. This discussion is simply about what can be done with C# and Avisynth.
I'm not saying things like if one is better than another
simply pointing out that some people have been misunderstanding C++ like how they assumed runtime hardware detection would be a problem in C++
C++17 is coming soon and they still have C++98 or even C in their mind and that's why they still have so much "fear" over C++

Last edited by feisty2; 1st March 2017 at 17:30.
feisty2 is offline   Reply With Quote
Old 1st March 2017, 17:59   #47  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
I think c# better for gui things, not for complex tasks like mp_pipeline

MysteryX, you say you will make AVSEdit work in x64 before, I think this better than mess with mpp in c#
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 2nd March 2017, 16:44   #48  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Quote:
Originally Posted by feisty2 View Post
no assembly required, include this header file in your project and it does all the dirty work for you automatically, also extremely easy to use
I never said (nor assumed) detecting the CPU type would be an issue.

But that still doesn't write any assembly. Even if dealing with that challenge I hadn't seen, one must still learn to write assembly and write assembly code for the various CPU infrastructures.
MysteryX is offline   Reply With Quote
Old 2nd March 2017, 16:54   #49  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 321
Quote:
Originally Posted by MysteryX View Post
But that still doesn't write any assembly. Even if dealing with that challenge I hadn't seen, one must still learn to write assembly and write assembly code for the various CPU infrastructures.
No, http://www.agner.org/optimize/#vectorclass.
Are_ is offline   Reply With Quote
Old 3rd March 2017, 02:20   #50  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Quote:
Originally Posted by MysteryX View Post
I never said (nor assumed) detecting the CPU type would be an issue.
I did say it, but only because I was saying that in C# you don't need to recompile a program every time, while in C++ you have to. Anyway, Feisty2 proved me that I was wrong, 'cause you can now specify which assembly optimisations use depending on CPU capabilities in C++, which is absolutely great.

Quote:
Originally Posted by real.finder
I think c# better for gui things
As a matter of fact, Blender and Visual Studio help a lot in making UI, especially for shared projects (projects that share codes between mobile and desktop).

Anyway, we are talking about avisynth filters here; that's a whole different scenario.
FranceBB is offline   Reply With Quote
Old 3rd March 2017, 23:02   #51  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
There are lots of C++ programs that auto-detect your CPU type and add assembly optimizations accordingly. FFMPEG and x264 are full of such optimizations.

It depends on how the code is structured and how the optimizations are implemented. There are other projects that require a different DLL per CPU type -- which is the case when you use compiler optimizations.
MysteryX is offline   Reply With Quote
Old 3rd March 2017, 23:20   #52  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by MysteryX View Post
There are other projects that require a different DLL per CPU type -- which is the case when you use compiler optimizations.
It depends. The Intel C/C++ compiler for example has an automatic CPU dispatcher, no need to build multiple binaries.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 21st March 2017, 23:21   #53  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
AvsFilterNet v1.0.3 is ready!

What's new:
- Fixed crash when an expection is thrown
- Can now initialize filter without child
- Fixed the code of LoadImageNet sample
- Added LoadAllPlugins sample that calls LoadPlugin and then calls the function
- Compiled with Visual Studio 2017
MysteryX is offline   Reply With Quote
Old 22nd March 2017, 17:04   #54  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
AvsFilterNet v1.0.4 is ready!

What's new:
- Error messages no longer include full stack trace
- Overriding GetFrame function is now optional
MysteryX is offline   Reply With Quote
Reply

Tags
.net, avisynth, filter

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 20:38.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.