optimization of lib function memcpy

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

optimization of lib function memcpy

1,317 次查看
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.

标记 (2)
0 项奖励
回复
3 回复数

1,050 次查看
Henrik-Wires
Contributor IV

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 项奖励
回复

1,276 次查看
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 项奖励
回复

1,178 次查看
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!

标记 (2)
0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2249255%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E4%BC%98%E5%8C%96%20lib%20%E5%87%BD%E6%95%B0%20memcpy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2249255%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E5%A4%A7%E5%AE%B6%E5%A5%BD%3C%2FP%3E%3CP%3E%E6%88%91%E7%9A%84%E9%A1%B9%E7%9B%AE%E5%BC%80%E5%8F%91%E4%BD%BF%E7%94%A8%E4%BA%86%20S32K344%20%E5%92%8C%20GCC%2010.2%E3%80%82%E5%9C%A8%E6%88%91%E7%9A%84%E9%A1%B9%E7%9B%AE%E4%B8%AD%EF%BC%8Cmemset%20%E5%92%8C%20memcpy%20%E8%A2%AB%E9%A2%91%E7%B9%81%E4%BD%BF%E7%94%A8%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E5%8F%91%E7%8E%B0%20lib%20%E4%B8%AD%E7%9A%84%20memcpy%20%E5%92%8C%20memset%20%E9%9D%9E%E5%B8%B8%E7%AE%80%E5%8D%95%E8%80%8C%E4%B8%94%E6%8C%89%E5%AD%97%E8%8A%82%E8%BF%90%E7%AE%97%E6%95%88%E7%8E%87%E5%BE%88%E4%BD%8E%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E4%BD%BF%E7%94%A8%20SIMD%20%E8%BF%90%E7%AE%97%E5%BC%80%E5%8F%91%E4%BA%86%E4%BC%98%E5%8C%96%E5%87%BD%E6%95%B0%E3%80%82%3C%2FP%3E%3CP%3E%E7%8E%B0%E5%9C%A8%EF%BC%8C%E6%88%91%E6%83%B3%E7%94%A8%E4%B8%80%E7%A7%8D%E9%80%8F%E6%98%8E%E7%9A%84%E6%96%B9%E6%B3%95%E6%9D%A5%E6%9B%BF%E6%8D%A2%20lib%20%E4%B8%AD%E7%9A%84%20memcpy%20%E5%92%8C%20memset%20%E5%87%BD%E6%95%B0%EF%BC%8C%E5%8D%B3%E5%9C%A8%E6%BA%90%E6%96%87%E4%BB%B6%E4%B8%AD%E4%BD%BF%E7%94%A8%20%23include%3CSTRING.H%3E%20%E3%80%82%3C%2FSTRING.H%3E%3C%2FP%3E%3CP%3E%E7%AD%89%E7%AD%89%EF%BC%8C%E4%BC%98%E5%8C%96%E5%90%8E%E7%9A%84%E5%87%BD%E6%95%B0%E8%A2%AB%E6%94%BE%E5%9C%A8%20.h%E6%96%87%E4%BB%B6%EF%BC%8C%E5%B9%B6%E4%BD%BF%E7%94%A8%E5%86%85%E8%81%94%E4%BF%AE%E6%94%B9%E5%99%A8%E3%80%82%3C%2FP%3E%3CP%3E%E6%98%AF%E5%90%A6%E6%9C%89%E5%8A%9E%E6%B3%95%E5%AE%9E%E7%8E%B0%E8%BF%99%E4%B8%80%E7%9B%AE%E6%A0%87%E3%80%82%3C%2FP%3E%3CP%3E%E8%B0%A2%E8%B0%A2%EF%BC%81%3C%2FP%3E%3CP%3E%E9%A1%BA%E7%A5%9D%E5%95%86%E7%A5%BA%EF%BC%81%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%E3%80%81%3CSPAN%3E%20%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%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E7%AD%94%E5%A4%8D%E3%80%82%E5%BA%93%E4%B8%AD%E7%9A%84%E6%8C%87%E4%BB%A4%E5%AF%B9%E6%88%91%E4%BB%AC%E7%9A%84%E9%A1%B9%E7%9B%AE%E6%9D%A5%E8%AF%B4%E6%95%88%E7%8E%87%E5%A4%AA%E4%BD%8E%E3%80%82%E4%BD%86%20memcpy%20%E5%AD%98%E5%9C%A8%E4%BA%8E%E8%AE%B8%E5%A4%9A%E6%BA%90%E6%96%87%E4%BB%B6%E4%B8%AD%EF%BC%8C%E6%9B%B4%E6%94%B9%E6%BA%90%E6%96%87%E4%BB%B6%E6%98%AF%E4%B8%8D%E5%8F%AF%E6%8E%A5%E5%8F%97%E7%9A%84%E3%80%82%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%E6%82%A8%E8%BF%98%E6%9C%89%E5%85%B6%E4%BB%96%E6%83%B3%E6%B3%95%E5%90%97%EF%BC%9F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%E9%A1%BA%E7%A5%9D%E5%95%86%E7%A5%BA%EF%BC%81%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%3E%E5%A6%82%E6%9E%9C%E5%9C%A8%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E4%B8%AD%E5%AE%9A%E4%B9%89%E4%BA%86%E5%85%A8%E5%B1%80%20memcpy%20%E5%87%BD%E6%95%B0%EF%BC%8C%E9%82%A3%E4%B9%88%E5%AE%83%E7%9A%84%E4%BC%98%E5%85%88%E7%BA%A7%E5%BA%94%E9%AB%98%E4%BA%8E%E5%BA%93%E4%B8%AD%E7%9A%84%E6%A0%87%E5%87%86%E5%87%BD%E6%95%B0%E3%80%82%E4%BD%86%E4%B8%8D%E8%83%BD%E5%86%85%E8%81%94%EF%BC%8C%E5%BF%85%E9%A1%BB%E4%BD%9C%E4%B8%BA%E6%A0%87%E5%87%86%E5%85%A8%E5%B1%80%EF%BC%88%E9%9D%9E%E9%9D%99%E6%80%81%EF%BC%89%E5%87%BD%E6%95%B0%E7%BC%96%E8%AF%91%E3%80%82%3C%2FP%3E%3CP%3E%E5%8F%A6%E4%B8%80%E7%A7%8D%E5%8F%AF%E8%A1%8C%E7%9A%84%E6%96%B9%E6%B3%95%E6%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