prefetch

Tensorflow Data API - prefetch

ぃ、小莉子 提交于 2019-12-20 18:33:43
问题 I am trying to use new features of TF, namely Data API, and I am not sure how prefetch works. In the code below def dataset_input_fn(...) dataset = tf.data.TFRecordDataset(filenames, compression_type="ZLIB") dataset = dataset.map(lambda x:parser(...)) dataset = dataset.map(lambda x,y: image_augmentation(...) , num_parallel_calls=num_threads ) dataset = dataset.shuffle(buffer_size) dataset = dataset.batch(batch_size) dataset = dataset.repeat(num_epochs) iterator = dataset.make_one_shot

What are _mm_prefetch() locality hints?

元气小坏坏 提交于 2019-12-20 09:06:05
问题 The intrinsics guide says only this much about void _mm_prefetch (char const* p, int i) : Fetch the line of data from memory that contains address p to a location in the cache heirarchy specified by the locality hint i. Could you list the possible values for int i parameter and explain their meanings? I've found _MM_HINT_T0 , _MM_HINT_T1 , _MM_HINT_T2 , _MM_HINT_NTA and _MM_HINT_ENTA , but I don't know whether this is an exhaustive list and what they mean. If processor-specific, I would like

How can I prefetch infrequently used code?

痴心易碎 提交于 2019-12-19 04:01:29
问题 I want to prefetch some code into the instruction cache. The code path is used infrequently but I need it to be in the instruction cache or at least in L2 for the rare cases that it is used. I have some advance notice of these rare cases. Does _mm_prefetch work for code? Is there a way to get this infrequently used code in cache? For this problem I don't care about portability so even asm would do. 回答1: The answer depends on your CPU architecture. That said, if you are using gcc or clang, you

Prefetching data to cache for x86-64

寵の児 提交于 2019-12-18 12:16:58
问题 In my application, at one point I need to perform calculations on a large contiguous block of memory data (100s of MBs). What I was thinking was to keep prefetching the part of the block my program will touch in future, so that when I perform calculations on that portion, the data is already in the cache. Can someone give me a simple example of how to achieve this with gcc? I read _mm_prefetch somewhere, but don't know how to properly use it. Also note that I have a multicore system, but each

The prefetch instruction

不问归期 提交于 2019-12-17 23:07:12
问题 It appears the general logic for prefetch usage is that prefetch can be added, provided the code is busy in processing until the prefetch instruction completes its operation. But, it seems that if too much of prefetch instructions are used, then it would impact the performance of the system. I find that we need to first have the working code without prefetch instruction. Later we need to various combination of prefetch instruction in various locations of code and do analysis to determine the

Does software prefetching allocate a Line Fill Buffer (LFB)?

那年仲夏 提交于 2019-12-17 22:19:35
问题 I've realized that Little's Law limits how fast data can be transferred at a given latency and with a given level of concurrency. If you want to transfer something faster, you either need larger transfers, more transfers "in flight", or lower latency. For the case of reading from RAM, the concurrency is limited by the number of Line Fill Buffers. A Line Fill Buffer is allocated when a load misses the L1 cache. Modern Intel chips (Nehalem, Sandy Bridge, Ivy Bridge, Haswell) have 10 LFB's per

What is the effect of second argument in _builtin_prefetch()?

巧了我就是萌 提交于 2019-12-17 20:55:09
问题 The GCC doc here specifies the usage of _buitin_prefetch. Third argument is perfect. If it is 0, compiler generates prefetchtnta (%rax) instruction If it is 1, compiler generates prefetcht2 (%rax) instruction If it is 2, compiler generates prefetcht1 (%rax) instruction If it is 3 (default), compiler generates prefetcht0 (%rax) instruction. If we vary third argument the opcode already changed accordingly. But second argument do not seem to have any effect. __builtin_prefetch(&x,1,2); __builtin

Prefetching double class member requires casting to char*?

好久不见. 提交于 2019-12-14 01:19:57
问题 I have a class which I am using _mm_prefetch() to pre-request the cacheline containing a class member, of type double: class MyClass{ double getDouble(){ return dbl; } //other members double dbl; //other members }; _mm_prefetch() signature is: void _mm_prefetch (char const* p, int i) But when I do: _mm_prefetch((char*)(myOb.getDouble()), _MM_HINT_T0); GCC complains: error: invalid cast from type 'double' to type 'char*' So how do I prefetch this class member? 回答1: If you read the description

How to turn off Safari's prefetch feature?

与世无争的帅哥 提交于 2019-12-12 11:41:56
问题 Safari has a "feature" which preloads pages while you are typing in the url. Now for most users this is indeed a feature, speeding up page loads. But for web developers it can cause trouble - especially when it automatically loads scripts (such as importers or background scripts) that you have used earlier but have no intention of running currently. This happens under Safari 8.x but it is possible that this was also the case on older versions. Also, note that this feature is distinct from

Automatically select related for OneToOne field

ⅰ亾dé卋堺 提交于 2019-12-12 10:54:24
问题 In my Django project I have a Profile for each django User, and the Profile is related to an Info model. Both relationships are OneToOne. Since most of the time I am using both the Profile and the Info models for a user, I would like those to be selected by default so I don't hit the database again. Is there any way to do this using Django authentication? 回答1: I know this has been here for a while but I am adding my solution in case someone else faces a similar situation. Django (as of v1.8