optimization of lib function memcpy

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

optimization of lib function memcpy

746 Views
LewisThin
Contributor III

hello everyone,

S32K344 and GCC 10.2 were used for my project developping. in my project, memset and memcpy were use freqently.

i found that the memcpy and memset in lib is vevry simple and low efficienct by byte operation.

i have developped the optimized functions using SIMD operations.

now i wanna to replace the memcpy and memset functions in the lib in a transparent method, namely, i wanna to use #include <string.h> in my source files.

and more, the optimized functions are in a .h file and with an inline modifier.

is there any way to achieve the goal.

thanks

best regards.

Tags (2)
0 Kudos
Reply
3 Replies

479 Views
Henrik-Wires
Contributor III

If you define a global memcpy function in your application then it should take priority over the standard function in the library. This can not be inline however, must be compiled as a standard global (non-static) function.

Another possible option is to add a define or alternatively a forced include via compiler directive settings, effectively rewriting the source files on the fly while compiling. Enabling your application and referenced drivers to use your version

0 Kudos
Reply

705 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @LewisThin 

We do not recommend replacing functions from standard libraries. However, if you need to use a custom function, you can create and add your own library. For detailed instructions, refer to HOWTO: Add a static library file into S32DS GCC project, where you will find further information that may be useful.

 

BR, VaneB

0 Kudos
Reply

607 Views
LewisThin
Contributor III

hi,  VaneB

Thanks for your reply. the instructions in  the lib are too inefficient for our project. but memcpy is in many sources files and changing the source files are not accepteable. 

do you have any other ideas?

best regards!

Tags (2)
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2249255%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Eoptimization%20of%20lib%20function%20memcpy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2249255%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Ehello%20everyone%2C%3C%2FP%3E%3CP%3ES32K344%20and%20GCC%2010.2%20were%20used%20for%20my%20project%20developping.%20in%20my%20project%2C%20memset%20and%20memcpy%20were%20use%20freqently.%3C%2FP%3E%3CP%3Ei%20found%20that%20the%20memcpy%20and%20memset%20in%20lib%20is%20vevry%20simple%20and%26nbsp%3Blow%20efficienct%20by%20byte%20operation.%3C%2FP%3E%3CP%3Ei%20have%20developped%20the%20optimized%20functions%20using%20SIMD%20operations.%3C%2FP%3E%3CP%3Enow%20i%20wanna%20to%20replace%20the%20memcpy%20and%20memset%20functions%20in%20the%20lib%20in%20a%20transparent%20method%2C%20namely%2C%20i%20wanna%20to%20use%20%23include%20%3CSTRING.H%3E%20in%20my%20source%20files.%3C%2FSTRING.H%3E%3C%2FP%3E%3CP%3Eand%20more%2C%20the%26nbsp%3Boptimized%20functions%20are%20in%20a%20.h%20file%20and%20with%20an%20inline%20modifier.%3C%2FP%3E%3CP%3Eis%20there%20any%20way%20to%20achieve%20the%20goal.%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3CP%3Ebest%20regards.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2249750%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20optimization%20of%20lib%20function%20memcpy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2249750%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F210005%22%20target%3D%22_blank%22%3E%40LewisThin%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20do%20not%20recommend%20replacing%20functions%20from%20standard%20libraries.%20However%2C%20if%20you%20need%20to%20use%20a%20custom%20function%2C%20you%20can%20create%20and%20add%20your%20own%20library.%20For%20detailed%20instructions%2C%20refer%20to%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32-Design-Studio-Knowledge-Base%2FHOWTO-Add-a-static-library-file-into-S32DS-GCC-project%2Fta-p%2F1110308%22%20target%3D%22_blank%22%3EHOWTO%3A%20Add%20a%20static%20library%20file%20into%20S32DS%20GCC%20project%3C%2FA%3E%2C%20where%20you%20will%20find%20further%20information%20that%20may%20be%20useful.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%2C%20VaneB%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2255766%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3Eoptimization%20of%20lib%20function%20memcpy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2255766%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Ehi%2C%26nbsp%3B%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F201913%22%20target%3D%22_self%22%3E%3CSPAN%20class%3D%22%22%3EVaneB%3C%2FSPAN%3E%3C%2FA%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3EThanks%20for%20your%20reply.%20the%20instructions%20in%26nbsp%3B%20the%20lib%20are%20too%20inefficient%20for%20our%20project.%20but%20memcpy%20is%20in%20many%20sources%20files%20and%20changing%20the%20source%20files%20are%20not%20accepteable.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3Edo%20you%20have%20any%20other%20ideas%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Ebest%20regards!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2260830%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20optimization%20of%20lib%20function%20memcpy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2260830%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIf%20you%20define%20a%20global%20memcpy%20function%20in%20your%20application%20then%20it%20should%20take%20priority%20over%20the%20standard%20function%20in%20the%20library.%20This%20can%20not%20be%20inline%20however%2C%20must%20be%20compiled%20as%20a%20standard%20global%20(non-static)%20function.%3C%2FP%3E%3CP%3EAnother%20possible%20option%20is%20to%20add%20a%20define%20or%20alternatively%20a%20forced%20include%20via%20compiler%20directive%20settings%2C%20effectively%20rewriting%20the%20source%20files%20on%20the%20fly%20while%20compiling.%20Enabling%20your%20application%20and%20referenced%20drivers%20to%20use%20your%20version%3C%2FP%3E%3C%2FLINGO-BODY%3E