Log in

View Full Version : Can Avisynth Plus MT determine the number of processor cores and returns this value?


silverwing
19th February 2019, 09:04
Hi, All!
One question.
Can Avisynth Plus MT determine the number of processor cores and returns this value? What function returns this value?
I need this value to substitute it into the Prefetch() function automatically (for multithreading).

I did it manually, but this is inconvenient, because I have to run the script on different computers with a different number of processor cores.

Is it possible?

Thank you for attention.
(Sorry for my bad English)

tebasuna51
19th February 2019, 10:35
Remember forum rule 8:

8) No cross posting. Post your message once, to the appropriate forum and nowhere else or it will be locked or deleted without warning.

The same post deleted in AviSynth+ thread.

Groucho2004
19th February 2019, 12:04
Avisynth does not provide a function to query the number of CPU cores (yet).
A simple plugin could return the number of cores although that function should really be in the core.

silverwing
19th February 2019, 13:16
Avisynth does not provide a function to query the number of CPU cores (yet).

Sad. It would be a very useful feature. :confused:

A simple plugin could return the number of cores although that function should really be in the core.

Is there such a plugin, Dear colleague?

Something like:

threads=CoreNumbers() + some_constant
Prefetch(threads)
or simple:
Prefetch( CoreNumbers() + some_constant )

Atak_Snajpera
19th February 2019, 13:32
Poke this gentelman here https://forum.doom9.org/showthread.php?p=1866097#post1866097

StainlessS
19th February 2019, 14:07
I thought that GetSystemEnv had already been added to Avs+, but not as of r2772.

but, can use this [from RT_Stats]

/*
RT_GetSystemEnv(String envname)
Returns a string from the System Environment with the env name of the string arg.
Returns "", if cannot find environment variable of given name.
eg, TEMP=RT_GetSystemEnv("TEMP") # to get TEMP folder path.
and eg
ComSpec=RT_GetSystemEnv("ComSpec") # might return "C:\WINDOWS\system32\cmd.exe"
To see the environment variables from command console, type 'set'.
http://en.wikipedia.org/wiki/Environment_variable


See Also StickBoy GetSystemEnv() :- http://www.avisynth.nl/users/stickboy/

*/


Colorbars(width=960).killaudio

OS = RT_GetSystemEnv("OS")
PROC_ARCH = RT_GetSystemEnv("PROCESSOR_ARCHITECTURE")
PROC_ID = RT_GetSystemEnv("PROCESSOR_IDENTIFIER")
NUMPROC = RT_GetSystemEnv("NUMBER_OF_PROCESSORS")

S = "OS = '" + OS + "'\n" +
\ "Processor Architecture = '" + PROC_ARCH + "'\n" +
\ "Processor Identifier = '" + PROC_ID + "'\n" +
\ "Processor Count = '" + NumProc + "'"


Subtitle(S,Font="Courier New",lsp=0)

NOTE, you may get different results if called from x86 or x64 process [from PROCESSOR_ARCHITECTURE].
EDIT: Dont know if NUMBER_OF_PROCESSORS includes hyperthreading or not, ie logical as well as physical cores (suspect that it will include both).

https://i.postimg.cc/n926Wpsf/NoCPU.jpg (https://postimg.cc/n926Wpsf)

silverwing
19th February 2019, 14:47
I thought that GetSystemEnv had already been added to Avs+, but not as of r2772.

but, can use this


Thank you! My CPU has hyperthreading. Your script shows correctly the number of logical cores. Good workaround! :thanks:

BTW.

I can't find in the source code (Avisynth Plus, downloaded from github) are internal functions like GetProcessInfo(), etc.
(It is possible that looking in the wrong direction.:confused: Someone tell me where to look?)

Otherwise, I would have put something like: GetLogicalProcessorInformation (Microsoft Sysinfo API (https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getlogicalprocessorinformation)).

Name? Simple! GetLogicalProcessorCores (). Add this code, compile, run. :D
And "In the bag"!

Atak_Snajpera
19th February 2019, 15:02
Keep in mind that AviSynth MT works better with prefetch equal to number of cores not logical cpus.

StainlessS
19th February 2019, 15:29
From Avisynth.cpp


size_t __stdcall ScriptEnvironment::GetProperty(AvsEnvProperty prop)
{
switch(prop)
{
case AEP_FILTERCHAIN_THREADS:
return (prefetcher != NULL) ? prefetcher->NumPrefetchThreads()+1 : 1;
case AEP_PHYSICAL_CPUS:
return GetNumPhysicalCPUs();
case AEP_LOGICAL_CPUS:
return std::thread::hardware_concurrency();
case AEP_THREAD_ID:
return 0;
case AEP_THREADPOOL_THREADS:
return thread_pool->NumThreads();
case AEP_VERSION:
return AVS_SEQREV;
default:
this->ThrowError("Invalid property request.");
return std::numeric_limits<size_t>::max();
}

assert(0);
}


Also see GetProperty in avisynth.h

EDIT: Not available for Avs Standard v2.60 (dont know about v2.61).

manolito
19th February 2019, 15:34
Keep in mind that AviSynth MT works better with prefetch equal to number of cores not logical cpus.

This has been discussed before, but in my experience this is not always true... :p
My CPU is an Intel Core i5 with 2 physical cores plus Hyperthreading, so it has 4 logical cores. The machine has 8GB RAM, and I use only AVS+ 32-bit.

Myrsloik proposed this formula for the number of threads:
It's possible that the default number of threads should be something like max(physical cores, min(logical threads, 8)) for x86

For my CPU this would mean 4. And indeed with AVS+ MT 32-bit Prefetch(4) so far has always been faster than Prefetch(2).


I use Stickboy's GetSystemEnv plugin to determine the NUMBER_OF_PROCESSORS environment variable which is 4 (win7-64). And this can be used directly with the Prefetch command. Like this:
Prefetch(Max(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS")))/2, MIN(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS"))),8)))

I know it looks ugly, but the typecast from string to int is required. Another problem is that the command assumes that the CPU has HyperThreading and HyperThreading is active.


Cheers
manolito

silverwing
19th February 2019, 15:35
Atak_Snajpera, This is a purely technical dispute. And I will not go into it, although I tried both the number of logical cores and the number of physical cores.
The question is different - to get the total number of processor(s) cores. StainlessS's script works. I just have to wait until this feature is added to the core of Avisynth Plus.
I hope this happens soon. :)

manolito
22nd February 2019, 00:47
Keep in mind that AviSynth MT works better with prefetch equal to number of cores not logical cpus.

A couple more speed benchmarks show that (at least on my machine) the results are different whether you only check the script with AVSMeter, or if you check the overall speed together with an encoder (I use X264 32-bit, the --threads param was not used so all available cores were used by X264).

It happened quite often that the script by itself was faster when using the number of physical cores for prefetch. But the overall speed was always faster when using all cores. (My Core i5 has 2 physical cores plus Hyperthreading, so I used either 2 or 4 as the prefetch values).


I am still thinking of a simple way to translate Myrsloik's formula into an AVS script automatically. My current prefetch command is this:
Prefetch(Max(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS")))/2, MIN(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS"))),8)))
This only works if HyperThreading is active, though.
Getting the logical cores is easy, I can use the environment variable NUMBER_OF_PROCESSORS. The problem is getting the number of physical cores.

So far I have come up with this:
The WMIC command can report the physical cores. I found a batch file which will export this value into an environment variable:

set PHYSICAL_CORES=0 & for /f "tokens=2 delims==" %%d in ('wmic cpu get NumberOfCores /value ^| findstr "="') do @set /A PHYSICAL_CORES+=%%d >NUL

Then the GetSystemEnv plugin can retrieve this variable.

To run this batch file I could use CallCmd. Haven't tried it yet, but I am not too sure if the environment variable which the batch file creates will be in the same process environment as the AVS script.

Anyone with a better (and simpler) idea?


Cheers
manolito


//EDIT//
After getting some test results from Selur and doing some serious thinking I decided to make it simpler. Going above 8 prefetch threads for AVS+ should only make sense in some rare situations, so I simplified Myrsloik's original algo:
max(physical cores, min(logical threads, 8))
to
min(logical threads, 8)
This will use the number of logical threads, but only up to 8. This should give good results in most cases. The prefetch command would be:
Prefetch(Min(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS"))),8))

Groucho2004
22nd February 2019, 01:35
The problem is getting the number of physical cores.This has become even more difficult with contemporary CPUs such as Ryzen. I went back to using Veselin Georgiev's libcpuid C-library (https://github.com/anrieff/libcpuid) in my programs which reports that value reliably and is frequently updated with the latest CPUs.

Looking at some comments (about Ryzen in this case) in the source of libcpuid shows how complex things have become:
/* Ryzen 3 has SMT flag, but in fact cores count is equal to threads count.
Ryzen 5/7 reports twice as many "real" cores (e.g. 16 cores instead of 8) because of SMT. */
/* On PPR 17h, page 82:
CPUID_Fn8000001E_EBX [Core Identifiers][15:8] is ThreadsPerCore
ThreadsPerCore: [...] The number of threads per core is ThreadsPerCore+1 */


That nice library could of course be integrated into a plugin or Avisynth itself.

Atak_Snajpera
22nd February 2019, 12:14
This has been discussed before, but in my experience this is not always true... :p
My CPU is an Intel Core i5 with 2 physical cores plus Hyperthreading, so it has 4 logical cores. The machine has 8GB RAM, and I use only AVS+ 32-bit.

Myrsloik proposed this formula for the number of threads:


For my CPU this would mean 4. And indeed with AVS+ MT 32-bit Prefetch(4) so far has always been faster than Prefetch(2).


I use Stickboy's GetSystemEnv plugin to determine the NUMBER_OF_PROCESSORS environment variable which is 4 (win7-64). And this can be used directly with the Prefetch command. Like this:


I know it looks ugly, but the typecast from string to int is required. Another problem is that the command assumes that the CPU has HyperThreading and HyperThreading is active.


Cheers
manolito

With cpu with higher number of cores for example 8 if I use prefetch with value higher than 8 then my script starts to choke and thus reducing average fps. This happens on Ryzen 7 and on my Xeon e5-2690.

silverwing
22nd February 2019, 12:35
That nice library could of course be integrated into a plugin or Avisynth itself.

"Avisynth itself" - best method. Out-of-box - no extra stuff! :D
I hope that a respected printerf will heed our wishes.

Groucho2004
22nd February 2019, 13:17
"Avisynth itself" - best method. Out-of-box - no extra stuff! :D
I hope that a respected printerf will heed our wishes.And if printerf doesn't, pinterf might. :D

manolito
22nd February 2019, 13:34
With cpu with higher number of cores for example 8 if I use prefetch with value higher than 8 then my script starts to choke and thus reducing average fps. This happens on Ryzen 7 and on my Xeon e5-2690.

According to Myrsloik's formula for such a CPU with 8 physical cores the result for Prefetch would be 8. What I am not sure about is the behavior for CPUs with a lot more than 8 physical cores, let's say 16.

With 16 physical cores the formula will give out 16, doesn't matter if HyperThreading is active or not. Is this good, or shouldn't the max number of Prefetch threads be capped, maybe to a maximum of 8?


Cheers
manolito

Groucho2004
22nd February 2019, 14:20
"Avisynth itself" - best method. Out-of-box - no extra stuff! :D
Using external libraries also has its drawbacks. You have to regularly check for updates (which in case of libcpuid is quite frequent since AMD/Intel keep releasing new CPUs). This adds to the workload for the person who maintains the project that uses the library. Also, what if the developer of the library stops development? It can be a PITA.

Atak_Snajpera
22nd February 2019, 14:47
According to Myrsloik's formula for such a CPU with 8 physical cores the result for Prefetch would be 8. What I am not sure about is the behavior for CPUs with a lot more than 8 physical cores, let's say 16.

With 16 physical cores the formula will give out 16, doesn't matter if HyperThreading is active or not. Is this good, or shouldn't the max number of Prefetch threads be capped, maybe to a maximum of 8?


Cheers
manolito

Like somebody explained to me reduction in speed is probably due to cache misses. I predict that on Threadripper we would see the same degradation in script processing.

wonkey_monkey
22nd February 2019, 15:05
And if printerf doesn't, pinterf might. :D

We should be using pinterf_s these days.

Selur
22nd February 2019, 15:06
According to Myrsloik's formula for such a CPU with 8 physical cores the result for Prefetch would be 8. What I am not sure about is the behavior for CPUs with a lot more than 8 physical cores, let's say 16.
As a site note:
Did a small test regarding the PreFetch value to test it at least on an 8 core system using:
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\LoadDll.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\DGDecodeNV.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\AddGrainC.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\dfttest.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\EEDI2.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\eedi3.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\FFT3DFilter.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\masktools2.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\mvtools2.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\nnedi.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\nnedi2.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\SSE2Tools.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\TDeint.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\VerticalCleanerSSE2.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\PlanarTools.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\MedianBlur2.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\nnedi3.dll")
LoadPlugin("I:\Hybrid\32bit\AVISYN~1\RgTools.dll")
LoadCPlugin("I:\Hybrid\32bit\AVISYN~1\yadif.dll")
LoadDLL("I:\Hybrid\32bit\AVISYN~1\libfftw3f-3.dll")
Import("I:\Hybrid\32bit\avisynthPlugins\QTGMC.avsi")
Import("I:\Hybrid\32bit\avisynthPlugins\SMDegrain.avsi")
Import("I:\Hybrid\32bit\avisynthPlugins\AnimeIVTC.avsi")
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
# loading source: F:\TestClips&Co\files\interlaceAndTelecineSamples\interlaced\burosch1.mpg
# input color sampling YV12
# input luminance scale tv
DGSource(dgi="E:\Temp\mpg_9f66a10dd7c34fcf28a5513f1347c0b5_853323747.dgi",fieldop=2)
# current resolution: 720x576
# deinterlacing
AssumeBFF()
QTGMC(Preset="Fast", ediThreads=2)
SelectEven()
# filtering
PreFetch(XXX)
return last

on a Ryzen 7 1800x using Avisynth+ 32bit.

XXX = 32
AviSynth+ 0.1 (r2772, MT, i386) (0.1.0.0)

Number of frames: 750
Length (hh:mm:ss.ms): 00:00:30.000
Frame width: 720
Frame height: 576
Framerate: 25.000 (25/1)
Colorspace: YV12

Frames processed: 750 (0 - 749)
FPS (min | max | average): 0.903 | 169492 | 40.74
Process memory usage (max): 1279 MiB
Thread count: 77
CPU usage (average): 67.1%

Time (elapsed): 00:00:18.412

XXX = 16:
AVSMeter 2.8.7 (x86) - Copyright (c) 2012-2018, Groucho2004
AviSynth+ 0.1 (r2772, MT, i386) (0.1.0.0)

Number of frames: 750
Length (hh:mm:ss.ms): 00:00:30.000
Frame width: 720
Frame height: 576
Framerate: 25.000 (25/1)
Colorspace: YV12

Frames processed: 750 (0 - 749)
FPS (min | max | average): 11.05 | 677.1 | 71.67
Process memory usage (max): 1003 MiB
Thread count: 60
CPU usage (average): 47.8%

Time (elapsed): 00:00:10.465


XXX = 8
AviSynth+ 0.1 (r2772, MT, i386) (0.1.0.0)

Number of frames: 750
Length (hh:mm:ss.ms): 00:00:30.000
Frame width: 720
Frame height: 576
Framerate: 25.000 (25/1)
Colorspace: YV12

Frames processed: 750 (0 - 749)
FPS (min | max | average): 21.01 | 111.3 | 76.13
Process memory usage (max): 603 MiB
Thread count: 53
CPU usage (average): 47.4%

Time (elapsed): 00:00:09.851

XXX = 4
AVSMeter 2.8.7 (x86) - Copyright (c) 2012-2018, Groucho2004
AviSynth+ 0.1 (r2772, MT, i386) (0.1.0.0)

Number of frames: 750
Length (hh:mm:ss.ms): 00:00:30.000
Frame width: 720
Frame height: 576
Framerate: 25.000 (25/1)
Colorspace: YV12

Frames processed: 750 (0 - 749)
FPS (min | max | average): 30.84 | 85.26 | 74.44
Process memory usage (max): 456 MiB
Thread count: 49
CPU usage (average): 43.7%

Time (elapsed): 00:00:10.075

XXX = 2
AVSMeter 2.8.7 (x86) - Copyright (c) 2012-2018, Groucho2004
AviSynth+ 0.1 (r2772, MT, i386) (0.1.0.0)

Number of frames: 750
Length (hh:mm:ss.ms): 00:00:30.000
Frame width: 720
Frame height: 576
Framerate: 25.000 (25/1)
Colorspace: YV12

Frames processed: 750 (0 - 749)
FPS (min | max | average): 30.41 | 57.26 | 54.85
Process memory usage (max): 361 MiB
Thread count: 48
CPU usage (average): 26.8%

Time (elapsed): 00:00:13.674


XXX = 1
AVSMeter 2.8.7 (x86) - Copyright (c) 2012-2018, Groucho2004
AviSynth+ 0.1 (r2772, MT, i386) (0.1.0.0)

Number of frames: 750
Length (hh:mm:ss.ms): 00:00:30.000
Frame width: 720
Frame height: 576
Framerate: 25.000 (25/1)
Colorspace: YV12

Frames processed: 750 (0 - 749)
FPS (min | max | average): 6.535 | 156.5 | 31.01
Process memory usage (max): 323 MiB
Thread count: 46
CPU usage (average): 16.9%

Time (elapsed): 00:00:24.184

-> at least on an 8 core system using PreFetch 8 seems to be good,...

Groucho2004
22nd February 2019, 18:49
XXX = 32

FPS (min | max | average): 0.903 | 169492 | 40.74
Process memory usage (max): 1279 MiB
Thread count: 77
CPU usage (average): 67.1%


XXX = 16:

FPS (min | max | average): 11.05 | 677.1 | 71.67
Process memory usage (max): 1003 MiB
Thread count: 60
CPU usage (average): 47.8%

XXX = 8

FPS (min | max | average): 21.01 | 111.3 | 76.13
Process memory usage (max): 603 MiB
Thread count: 53
CPU usage (average): 47.4%

XXX = 4

FPS (min | max | average): 30.84 | 85.26 | 74.44
Process memory usage (max): 456 MiB
Thread count: 49
CPU usage (average): 43.7%

-> at least on an 8 core system using PreFetch 8 seems to be good,...
Looking at efficiency, a value of 4 would be even better. Almost the same speed as 8 but less CPU/memory usage. Maybe something between 4 and 8 would be the optimum in this particular case.

manolito
22nd February 2019, 18:54
Thanks Selur for these test results... :cool:

They confirm my suspicion that the advantage of using AVS+ MT has a peak somewhere (probably around 8 threads) no matter how many cores the CPU offers. Of course there are other things to consider like source characteristics, complexity of the script and amount of RAM, but this cannot be automated.

So I decided to simplify the algo for determining the optimal number of prefetch threads to:
min(logical threads, 8)
This will use the number of logical cores (including HyperThreading), but only up to 8. Should give good results in the majority of situations.

The Prefetch command would then look like this:
Prefetch(Min(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS"))),8))


Cheers
manolito

manolito
22nd February 2019, 19:04
Looking at efficiency, a value of 4 would be even better. Almost the same speed as 8 but less CPU/memory usage. Maybe something between 4 and 8 would be the optimum in this particular case.

True, but as I said before, at least on my machine the AVSMeter results do not show the whole picture. The overall speed when doing a real encode (X264 32-bit in my case) looks better when the number of prefetch threads is equal to the number of logical threads, even when AVSMeter alone shows better speed with a lower prefetch value.

Groucho2004
22nd February 2019, 19:19
True, but as I said before, at least on my machine the AVSMeter results do not show the whole picture. The overall speed when doing a real encode (X264 32-bit in my case) looks better when the number of prefetch threads is equal to the number of logical threads, even when AVSMeter alone shows better speed with a lower prefetch value.True, when you include the encoder in the chain, things get even more complex.
I believe it mostly depends on the script and the plugins used how well the speed scales with the number of threads.

StainlessS
22nd February 2019, 20:07
For myself, I dont ever (up to now) bother with all of the MT, or whatever settings, let it do its stuff, is my philosophy,
assign a job to your last best machine, tell if to shut down on completion, not a bother, who cares how long it takes, you're asleep anyyway.

EDIT: of course for this to work, you have to keep your last best macine, to actually do the work,,
and your current macine is basically and editor. (should really be the other way around).

johnmeyer
22nd February 2019, 20:21
For myself, I dont ever (up to now) bother with all of the MT, or whatever settings, let it do its stuff, is my philosophy,
assign a job to your last best machine, tell if to shut down on completion, not a bother, who cares how long it takes, you're asleep anyyway.When it takes three days without MT, and when you've got five projects to do, and when you have a client who wants one of those projects yesterday, then it matters.

Time is money.

ChaosKing
22nd February 2019, 20:42
The best speedup is still to encode stuff in parallel. Split your video in X parts, encode video 1,2,3, 4 ... n to a lossless format -> make final encode! Send homing pigeon with usb drive to client. Take a nap.

Atak_Snajpera
23rd February 2019, 14:21
CPU: Xeon E5-2690 (8C/16T)
Script

#MT
Import("C:\Users\Dave\Documents\Delphi_Projects\RipBot264\_Compiled\Tools\AviSynth plugins\Scripts\MTmodes.avs")

#VideoSource
LoadPlugin("C:\Users\Dave\Documents\Delphi_Projects\RipBot264\_Compiled\Tools\AviSynth plugins\ffms\ffms_latest\x64\ffms2.dll")
video=FFVideoSource("..\LG Rays of Light 4K Demo.ts")


#Tonemap
Loadplugin("C:\Users\Dave\Documents\Delphi_Projects\RipBot264\_Compiled\Tools\AviSynth plugins\avsresize\avsresize.dll")
Loadplugin("C:\Users\Dave\Documents\Delphi_Projects\RipBot264\_Compiled\Tools\AviSynth plugins\DGTonemap\x64\DGTonemap.dll")
video=z_ConvertFormat(video,pixel_type="RGBPS",colorspace_op="2020ncl:st2084:2020:l=>rgb:linear:2020:l", dither_type="none").DGHable(exposure=1.0)
video=z_ConvertFormat(video,pixel_type="YV12",colorspace_op="rgb:linear:2020:l=>709:709:709:l",dither_type="ordered")


#Prefetch
video=Prefetch(video,X)

Prefetch scalling
https://i.imgsafe.org/18/18ef1553fc.png

Choking effect with prefetch 16. Notice how uneven is prefetch 16!
https://i.imgsafe.org/14/14831b93c0.png

manolito
23rd February 2019, 18:12
Thanks Atak for these tests...

Your and Selur's tests lead to 2 possible conclusions:

1. Use the number of physical cores as the prefetch value
2. Limit the prefetch value to 8, but for a CPU with less than 8 physical cores use all available cores including HyperThreading.

I tend to use conclusion #2, any objections?


Cheers
manolito

Taurus
23rd February 2019, 18:54
We should be using pinterf_s these days.
or (s)p(r)interf :D
Sorry, could not resist...

Atak_Snajpera
23rd February 2019, 20:25
Thanks Atak for these tests...

Your and Selur's tests lead to 2 possible conclusions:

1. Use the number of physical cores as the prefetch value
2. Limit the prefetch value to 8, but for a CPU with less than 8 physical cores use all available cores including HyperThreading.

I tend to use conclusion #2, any objections?


Cheers
manolito

I've disabled two cores in BIOS and on 6c/12t I still see the same bad behaviour.

prefetch(6) = 14.4 fps
prefetch(12) = 11.3 fps

https://i.imgsafe.org/19/19e0e7f924.png

Rule is simple! Prefetch = physical cores. End of story! Anything above = choking effect.

wonkey_monkey
23rd February 2019, 20:34
A warning, as people still seem to be posting directly to threads and may not be aware:

It appears that the forum may have been hacked. There is a suspicious "test" announcement, apparently from tebasuna51 (but probably not), parts of the forum are not working, and there appear to be some malicious javascript files.

I'm not speaking in any official capacity here, but I would recommend, at the very least, NOT entering your password anywhere on Doom9 for the time being.

Please refer to this post: https://forum.doom9.org/showthread.php?goto=newpost&t=176128

Groucho2004
23rd February 2019, 23:25
I rustled up a plugin that uses libcpuid.

The first two functions I implemented are:
SI_PhysicalCores()
SI_LogicalCores()

No arguments, functions return int. If the CPU detection fails they return -1.



Edit: SysInfo plugin released -> https://forum.doom9.org/showthread.php?t=176131

ChaosKing
23rd February 2019, 23:41
Ryzen 1700 PhysicalCores 8 LogicalCores 16. Works good, thx.

manolito
24th February 2019, 01:03
Let me know if they return the correct values for your CPU (they really should :cool:)

Thanks Groucho, very useful...

Works perfectly on the 2 computers I tested it. Even the ancient desktop machine with an Intel Coppermine (No SSE2) reports the correct number of cores - not that it matters...


Cheers
manolito

manolito
24th February 2019, 01:08
Rule is simple! Prefetch = physical cores. End of story! Anything above = choking effect.

How about testing with 4/8 and 2/4 cores? And with 6/12 cores comparing the results for 6 and 8 prefetch threads? And maybe even measuring the overall speed with an added encoder?

All I can speak for is my Core i5 with 2c/4t, and this one is always faster using 4 prefetch threads compared to using only 2.

StainlessS
24th February 2019, 16:12
Dont know if of any use, but my P4 [single physical core] with hyperthreading always was about twice as fast at encode than my P4 without.
(cant check, I recently dumped two P4's without hyperthreading, least best now P4 with hyperthreading).
Above without any "Threads" or similar setting, just always on default.
EDIT: P4 without ~2.88GHz[socket 478], With hyperthreading 3GHz[socket 775, IBM Think Center].
EDIT: Both DDR1.