optimization

const reference to temporary vs. return value optimization

雨燕双飞 提交于 2019-12-31 10:34:12
问题 I'm aware of the fact that assigning an rvalue to a const lvalue reference extends the temporaries lifetime until the end of the scope. However, it is not clear to me when to use this and when to rely on the return value optimization. LargeObject lofactory( ... ) { // construct a LargeObject in a way that is OK for RVO/NRVO } int main() { const LargeObject& mylo1 = lofactory( ... ); // using const& LargeObject mylo2 = lofactory( ... ); // same as above because of RVO/NRVO ? } According to

Can't get over 50% max. theoretical performance on matrix multiply

一世执手 提交于 2019-12-31 10:22:41
问题 Problem I am learning about HPC and code optimization. I attempt to replicate the results in Goto's seminal matrix multiplication paper (http://www.cs.utexas.edu/users/pingali/CS378/2008sp/papers/gotoPaper.pdf). Despite my best efforts, I cannot get over ~50% maximum theoretical CPU performance. Background See related issues here (Optimized 2x2 matrix multiplication: Slow assembly versus fast SIMD), including info about my hardware What I have attempted This related paper (http://www.cs

Can't get over 50% max. theoretical performance on matrix multiply

醉酒当歌 提交于 2019-12-31 10:22:08
问题 Problem I am learning about HPC and code optimization. I attempt to replicate the results in Goto's seminal matrix multiplication paper (http://www.cs.utexas.edu/users/pingali/CS378/2008sp/papers/gotoPaper.pdf). Despite my best efforts, I cannot get over ~50% maximum theoretical CPU performance. Background See related issues here (Optimized 2x2 matrix multiplication: Slow assembly versus fast SIMD), including info about my hardware What I have attempted This related paper (http://www.cs

GCC/Make Build Time Optimizations

…衆ロ難τιáo~ 提交于 2019-12-31 10:01:53
问题 We have project which uses gcc and make files. Project also contains of one big subproject (SDK) and a lot of relatively small subprojects which use that SDK and some shared framework. We use precompiled headers, but that helps only for re-compilation to be faster. Is there any known techniques and tools to help with build-time optimizations? Or maybe you know some articles/resources about this or related topics? 回答1: You can tackle the problem from two sides: refactor the code to reduce the

GCC/Make Build Time Optimizations

最后都变了- 提交于 2019-12-31 10:01:47
问题 We have project which uses gcc and make files. Project also contains of one big subproject (SDK) and a lot of relatively small subprojects which use that SDK and some shared framework. We use precompiled headers, but that helps only for re-compilation to be faster. Is there any known techniques and tools to help with build-time optimizations? Or maybe you know some articles/resources about this or related topics? 回答1: You can tackle the problem from two sides: refactor the code to reduce the

Tutorials on optimizing non-trivial Python applications with C extensions or Cython

微笑、不失礼 提交于 2019-12-31 08:59:47
问题 The Python community has published helpful reference material showing how to profile Python code, and the technical details of Python extensions in C or in Cython. I am still searching for tutorials which show, however, for non-trivial Python programs, the following: How to identify the hotspots which will benefit from optimization by conversion to a C extension Just as importantly, how to identify the hotspots which will not benefit from conversion to a C extension Finally, how to make the

Django - rendering many templates using templatetags is very slow

空扰寡人 提交于 2019-12-31 08:48:08
问题 Say, I have a page with a photo gallery. Each thumbnail has e.g. a photo, country, author and so on. I render these items/widgets using template tags (which load specified templates) - it goes that way because of DRY (I use these items/widgets separately in different places on the page). And it is very slow. I have performed some profiling using django-debug-toolbar: SQL Queries: default 84.81 ms (147 queries) But: Total CPU time: 5768.360 msec Which is too long to wait. After some analysis

More efficient algorithm for shortest superstring search

♀尐吖头ヾ 提交于 2019-12-31 08:39:09
问题 My problem below is NP-complete, however, I'm trying to find at least a marginally faster string search function or module that might help in reducing some of the computation time compared to where it is at now. Any suggestions would be appreciated. The concatenated (longest possible) superstring is: AGGAGTCCGCGTGAGGGAGGTGTAGTGTAGTGG The below code produces the shortest superstring in 16m: CCGTAGGTGGAGT import itertools as it def main(): seqs = ['AGG', 'AGT', 'CCG', 'CGT', 'GAG', 'GGA', 'GGT'

How can I efficiently create unique relationships in Neo4j?

只愿长相守 提交于 2019-12-31 06:59:07
问题 Following up on my question here, I would like to create a constraint on relationships. That is, I would like there to be multiple nodes that share the same "neighborhood" name, but each uniquely point to a particular city in which they reside. As encouraged in user2194039's answer, I am using the following index: CREATE INDEX ON :Neighborhood(name) Also, I have the following constraint: CREATE CONSTRAINT ON (c:City) ASSERT c.name IS UNIQUE; The following code fails to create unique

Linq2Sql: query - subquery optimisation

元气小坏坏 提交于 2019-12-31 06:17:04
问题 I have the following query: IList<InfrStadium> stadiums = (from sector in DbContext.sectors where sector.Type=typeValue select new InfrStadium(sector.TeamId) ).ToList(); and InfrStadium class constructor: private InfrStadium(int teamId) { IList<Sector> teamSectors = (from sector in DbContext.sectors where sector.TeamId==teamId select sector) .ToList<>(); ... work with data } Current implementation perform 1+n queries, where n - number of records fetched the 1st time. I want to optimize that.