Skip to content

Commit 67ae312

Browse files
authored
Merge branch 'master' into master
2 parents 9374e1b + 4c35daf commit 67ae312

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

src/TrigBufCache.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ TrigBufCache::~TrigBufCache() = default;
334334
TrigPtr TrigBufCache::smallTrig(u32 W, u32 nW) {
335335
lock_guard lock{mut};
336336
auto& m = small;
337-
decay_t<decltype(m)>::key_type key{W, nW};
337+
decay_t<decltype(m)>::key_type key{W, nW, 0, 0};
338338

339339
TrigPtr p{};
340340
auto it = m.find(key);
@@ -347,21 +347,22 @@ TrigPtr TrigBufCache::smallTrig(u32 W, u32 nW) {
347347
}
348348

349349
TrigPtr TrigBufCache::smallTrigCombo(u32 width, u32 middle, u32 W, u32 nW) {
350-
lock_guard lock{mut};
351-
auto& m = small;
352350
#if PREFER_DP_TO_MEM == 2 // No pre-computed trig values
353-
decay_t<decltype(m)>::key_type key{W, nW};
354-
#else
355-
// Hack so that width 512 and height 512 don't share the same buffer. Width could share the height buffer since it is a subset of the combo height buffer.
356-
// Also add in middle so that 512:15:512 does not share buffer with 512:14:512.
357-
decay_t<decltype(m)>::key_type key{W, nW+middle};
351+
return smallTrig(W, nW);
358352
#endif
359353

354+
lock_guard lock{mut};
355+
auto& m = small;
356+
decay_t<decltype(m)>::key_type key1{W, nW, width, middle};
357+
// We write the "combo" under two keys, so it can also be retrieved as non-combo by smallTrig()
358+
decay_t<decltype(m)>::key_type key2{W, nW, 0, 0};
359+
360360
TrigPtr p{};
361-
auto it = m.find(key);
361+
auto it = m.find(key1);
362362
if (it == m.end() || !(p = it->second.lock())) {
363363
p = make_shared<TrigBuf>(context, genSmallTrigCombo(width, middle, W, nW));
364-
m[key] = p;
364+
m[key1] = p;
365+
m[key2] = p;
365366
smallCache.add(p);
366367
}
367368
return p;

src/TrigBufCache.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ class TrigBufCache {
2727
const Context* context;
2828
std::mutex mut;
2929

30-
std::map<tuple<u32, u32>, TrigPtr::weak_type> small;
30+
std::map<tuple<u32, u32, u32, u32>, TrigPtr::weak_type> small;
3131
std::map<tuple<u32, u32, u32>, TrigPtr::weak_type> middle;
3232

3333
// The shared-pointers below keep the most recent set of buffers alive even without any Gpu instance
3434
// referencing them. This allows a single worker to delete & re-create the Gpu instance and still reuse the buffers.
35-
StrongCache smallCache{6};
36-
StrongCache middleCache{6};
35+
StrongCache smallCache{4};
36+
StrongCache middleCache{4};
3737

3838
public:
3939
TrigBufCache(const Context* context) :

tools/primenet.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,15 @@ def fetch(what):
7474
# print(res)
7575

7676
BEGIN_MARK = "<!--BEGIN_ASSIGNMENTS_BLOCK-->"
77-
begin = res.find("<!--BEGIN_ASSIGNMENTS_BLOCK-->")
78-
if begin == -1: raise(AssertionError("assignment no BEGIN mark"))
79-
begin += len(BEGIN_MARK)
80-
end = res.find("<!--END_ASSIGNMENTS_BLOCK-->", begin)
77+
# begin = res.find(BEGIN_MARK)
78+
begin = res.find(">PRP=")
79+
if begin == -1: begin = res.find(">LL=")
80+
if begin == -1:
81+
print(res)
82+
raise(AssertionError("assignment no BEGIN mark"))
83+
begin += 1
84+
# begin += len(BEGIN_MARK)
85+
end = res.find("</", begin)
8186
if end == -1: raise(AssertionError("assignemnt no END mark"))
8287
line = res[begin:end].strip().strip('\n')
8388
print(datetime.now(), " New assignment: ", line)

0 commit comments

Comments
 (0)