Hi all,
Does anyone know of a way to achieve multi-theaded platform invokes? I have
been taking quite a performance hit using the syncronised attribute:
[MethodImpl(MethodImplOptions.Synchronized)].
Cheers
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004 5 1762
Duncan,
Are you attributing the actual function delcaration with MethodImpl? If
so, then this is probably a bad idea, since it will lock on the type, and if
you have multiple method definitions on the same type, they will all lock on
the same thing (when it probably isn't required).
Are you sure that your library functions are not re-entrant? Are you
sure you have to do this?
If so, then what you should do is create an object (new object()) for
each function that you declare. Declare them as private, and then write
static wrappers around them. In the static wrapper, lock on the object that
corresponds to the method that you are calling through the P/Invoke layer.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Duncan Mole" <du**************************@ntlworld.com> wrote in message
news:Yx*****************@newsfe3-gui.ntli.net... Hi all,
Does anyone know of a way to achieve multi-theaded platform invokes? I have been taking quite a performance hit using the syncronised attribute: [MethodImpl(MethodImplOptions.Synchronized)].
Cheers
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004
Hi Nicholas,
Thanks for the quick response. I am only assuming that they are not
re-entrant because I was getting exceptions being thrown once I have moved
into mutli-threaded processesing that weren't there in the single threaded
versions: "Object not set to an instance of an object"; I am still in the
process of figuring out why this is. I am thinking maybe its my interop
complaining not the dll - but if I must declare pinvokes as static extern,
how can I avoid it?
I can see how your solution benefits me in that I lock on a single method
rather than the type that owns it however I am working with an encoding dll
that will bottleneck on one particualar method so the improvement will not
be that marked.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uK**************@TK2MSFTNGP12.phx.gbl... Duncan,
Are you attributing the actual function delcaration with MethodImpl?
If so, then this is probably a bad idea, since it will lock on the type, and
if you have multiple method definitions on the same type, they will all lock
on the same thing (when it probably isn't required).
Are you sure that your library functions are not re-entrant? Are you sure you have to do this?
If so, then what you should do is create an object (new object()) for each function that you declare. Declare them as private, and then write static wrappers around them. In the static wrapper, lock on the object
that corresponds to the method that you are calling through the P/Invoke layer.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Duncan Mole" <du**************************@ntlworld.com> wrote in message news:Yx*****************@newsfe3-gui.ntli.net... Hi all,
Does anyone know of a way to achieve multi-theaded platform invokes? I have been taking quite a performance hit using the syncronised attribute: [MethodImpl(MethodImplOptions.Synchronized)].
Cheers
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004
Duncan,
If the bottleneck will be on one particular method, then how is it the
synchronization of the calls to the DLL functions which is causing the
bottleneck? Based on what you said, it would seem this is not the case, and
that in fact, something else is amiss.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Duncan Mole" <du**************************@ntlworld.com> wrote in message
news:rX****************@newsfe3-gui.ntli.net... Hi Nicholas,
Thanks for the quick response. I am only assuming that they are not re-entrant because I was getting exceptions being thrown once I have moved into mutli-threaded processesing that weren't there in the single threaded versions: "Object not set to an instance of an object"; I am still in the process of figuring out why this is. I am thinking maybe its my interop complaining not the dll - but if I must declare pinvokes as static extern, how can I avoid it?
I can see how your solution benefits me in that I lock on a single method rather than the type that owns it however I am working with an encoding dll that will bottleneck on one particualar method so the improvement will not be that marked.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:uK**************@TK2MSFTNGP12.phx.gbl... Duncan,
Are you attributing the actual function delcaration with MethodImpl? If so, then this is probably a bad idea, since it will lock on the type, and if you have multiple method definitions on the same type, they will all lock on the same thing (when it probably isn't required).
Are you sure that your library functions are not re-entrant? Are you sure you have to do this?
If so, then what you should do is create an object (new object()) for each function that you declare. Declare them as private, and then write static wrappers around them. In the static wrapper, lock on the object that corresponds to the method that you are calling through the P/Invoke layer.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Duncan Mole" <du**************************@ntlworld.com> wrote in message news:Yx*****************@newsfe3-gui.ntli.net... > Hi all, > > Does anyone know of a way to achieve multi-theaded platform invokes? I > have > been taking quite a performance hit using the syncronised attribute: > [MethodImpl(MethodImplOptions.Synchronized)]. > > Cheers > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004 > >
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004
Yeah, thats what I was *slowly* figuring. Can you see a problem with the
following
public static uint EncodeChunk(uint hbeStream, byte[] buffer, int index,
uint nBytes, byte[] pOutput, ref uint pdwOutput)
{
uint res = 0;
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
try
{
IntPtr ptr = (IntPtr)(handle.AddrOfPinnedObject().ToInt32()+ind ex);
res = beEncodeChunk(hbeStream, nBytes/2/*Samples*/, ptr, pOutput, ref
pdwOutput);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
handle.Free();
}
return res;
}
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl... Duncan,
If the bottleneck will be on one particular method, then how is it the synchronization of the calls to the DLL functions which is causing the bottleneck? Based on what you said, it would seem this is not the case,
and that in fact, something else is amiss.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Duncan Mole" <du**************************@ntlworld.com> wrote in message news:rX****************@newsfe3-gui.ntli.net... Hi Nicholas,
Thanks for the quick response. I am only assuming that they are not re-entrant because I was getting exceptions being thrown once I have
moved into mutli-threaded processesing that weren't there in the single
threaded versions: "Object not set to an instance of an object"; I am still in
the process of figuring out why this is. I am thinking maybe its my interop complaining not the dll - but if I must declare pinvokes as static
extern, how can I avoid it?
I can see how your solution benefits me in that I lock on a single
method rather than the type that owns it however I am working with an encoding dll that will bottleneck on one particualar method so the improvement will
not be that marked.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:uK**************@TK2MSFTNGP12.phx.gbl... Duncan,
Are you attributing the actual function delcaration with
MethodImpl? If so, then this is probably a bad idea, since it will lock on the type,
and if you have multiple method definitions on the same type, they will all
lock on the same thing (when it probably isn't required).
Are you sure that your library functions are not re-entrant? Are
you sure you have to do this?
If so, then what you should do is create an object (new object())
for each function that you declare. Declare them as private, and then
write static wrappers around them. In the static wrapper, lock on the object that corresponds to the method that you are calling through the P/Invoke layer.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Duncan Mole" <du**************************@ntlworld.com> wrote in message news:Yx*****************@newsfe3-gui.ntli.net... > Hi all, > > Does anyone know of a way to achieve multi-theaded platform invokes?
I > have > been taking quite a performance hit using the syncronised attribute: > [MethodImpl(MethodImplOptions.Synchronized)]. > > Cheers > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004 > >
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004
Duncan,
Why are you pinning the address of the array? There isn't much reason
to do that, the P/Invoke layer will handle all of that for you (unless the
array is being held by the function somewhere else and operated on outside
of the call).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Duncan Mole" <du**************************@ntlworld.com> wrote in message
news:zK*****************@newsfe3-gui.ntli.net... Yeah, thats what I was *slowly* figuring. Can you see a problem with the following
public static uint EncodeChunk(uint hbeStream, byte[] buffer, int index, uint nBytes, byte[] pOutput, ref uint pdwOutput)
{
uint res = 0;
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
try
{
IntPtr ptr = (IntPtr)(handle.AddrOfPinnedObject().ToInt32()+ind ex);
res = beEncodeChunk(hbeStream, nBytes/2/*Samples*/, ptr, pOutput, ref pdwOutput);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
handle.Free();
}
return res;
}
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... Duncan,
If the bottleneck will be on one particular method, then how is it the synchronization of the calls to the DLL functions which is causing the bottleneck? Based on what you said, it would seem this is not the case, and that in fact, something else is amiss.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Duncan Mole" <du**************************@ntlworld.com> wrote in message news:rX****************@newsfe3-gui.ntli.net... > Hi Nicholas, > > Thanks for the quick response. I am only assuming that they are not > re-entrant because I was getting exceptions being thrown once I have moved > into mutli-threaded processesing that weren't there in the single threaded > versions: "Object not set to an instance of an object"; I am still in the > process of figuring out why this is. I am thinking maybe its my interop > complaining not the dll - but if I must declare pinvokes as static extern, > how can I avoid it? > > I can see how your solution benefits me in that I lock on a single method > rather than the type that owns it however I am working with an encoding > dll > that will bottleneck on one particualar method so the improvement will not > be that marked. > > > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> > wrote > in > message news:uK**************@TK2MSFTNGP12.phx.gbl... >> Duncan, >> >> Are you attributing the actual function delcaration with MethodImpl? > If >> so, then this is probably a bad idea, since it will lock on the type, and > if >> you have multiple method definitions on the same type, they will all lock > on >> the same thing (when it probably isn't required). >> >> Are you sure that your library functions are not re-entrant? Are you >> sure you have to do this? >> >> If so, then what you should do is create an object (new object()) for >> each function that you declare. Declare them as private, and then write >> static wrappers around them. In the static wrapper, lock on the >> object > that >> corresponds to the method that you are calling through the P/Invoke >> layer. >> >> Hope this helps. >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "Duncan Mole" <du**************************@ntlworld.com> wrote in >> message >> news:Yx*****************@newsfe3-gui.ntli.net... >> > Hi all, >> > >> > Does anyone know of a way to achieve multi-theaded platform invokes? I >> > have >> > been taking quite a performance hit using the syncronised attribute: >> > [MethodImpl(MethodImplOptions.Synchronized)]. >> > >> > Cheers >> > >> > >> > --- >> > Outgoing mail is certified Virus Free. >> > Checked by AVG anti-virus system (http://www.grisoft.com). >> > Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004 >> > >> > >> >> > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004 > >
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ajikoe |
last post by:
Hello,
Is anyone has experiance in running python code to run multi thread
parallel in multi processor. Is it possible ?
Can python manage which cpu shoud do every thread?
Sincerely Yours,...
|
by: Frank Jona |
last post by:
Intellisense with C# and a multi-file assembly is not
working. With VB.NET it is working.
Is there a fix availible?
We're using VisualStudio 2003
Regards
Frank
|
by: * ProteanThread * |
last post by:
but depends upon the clique:
...
|
by: frankenberry |
last post by:
I have multi-page tiff files. I need to extract individual frames from the
multi-page tiffs and save them as single-page tiffs. 95% of the time I
receive multi-page tiffs containing 1 or more black...
|
by: cody |
last post by:
What are multi file assemblies good for?
What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a
single multi file assembly (A.DLL+A.NETMODULE)?
|
by: mimmo |
last post by:
Hi! I should convert the accented letters of a string in the correspondent
letters not accented. But when I compile with -Wall it give me:
warning: multi-character character constant
Do the...
|
by: Shane Story |
last post by:
I can seem to get the dimensions of a frame in a multiframe tiff.
After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.
When I split a...
|
by: bobwansink |
last post by:
Hi, I'm relatively new to programming and I would like to create a C++
multi user program. It's for a project for school. This means I will
have to write a paper about the theory too. Does anyone...
|
by: Sabri.Pllana |
last post by:
We apologize if you receive multiple copies of this call for papers.
***********************************************************************
2008 International Workshop on Multi-Core Computing...
|
by: mknoll217 |
last post by:
I am recieving this error from my code:
The multi-part identifier "PAR.UniqueID" could not be bound.
The multi-part identifier "Salary.UniqueID" could not be bound.
The multi-part identifier...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |