aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/UI/GUI/CompressDialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/UI/GUI/CompressDialog.cpp')
-rw-r--r--CPP/7zip/UI/GUI/CompressDialog.cpp129
1 files changed, 63 insertions, 66 deletions
diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp
index 85d7186..53e56fe 100644
--- a/CPP/7zip/UI/GUI/CompressDialog.cpp
+++ b/CPP/7zip/UI/GUI/CompressDialog.cpp
@@ -506,8 +506,7 @@ bool CCompressDialog::OnInit()
506 { 506 {
507 const unsigned arcIndex = ArcIndices[i]; 507 const unsigned arcIndex = ArcIndices[i];
508 const CArcInfoEx &ai = (*ArcFormats)[arcIndex]; 508 const CArcInfoEx &ai = (*ArcFormats)[arcIndex];
509 const int index = (int)m_Format.AddString(ai.Name); 509 const int index = (int)m_Format.AddString_SetItemData(ai.Name, (LPARAM)arcIndex);
510 m_Format.SetItemData(index, (LPARAM)arcIndex);
511 if (!needSetMain) 510 if (!needSetMain)
512 { 511 {
513 if (Info.FormatIndex == (int)arcIndex) 512 if (Info.FormatIndex == (int)arcIndex)
@@ -540,11 +539,6 @@ bool CCompressDialog::OnInit()
540 AddComboItems(m_PathMode, k_PathMode_IDs, Z7_ARRAY_SIZE(k_PathMode_IDs), 539 AddComboItems(m_PathMode, k_PathMode_IDs, Z7_ARRAY_SIZE(k_PathMode_IDs),
541 k_PathMode_Vals, Info.PathMode); 540 k_PathMode_Vals, Info.PathMode);
542 541
543
544 TCHAR s[32] = { TEXT('/'), TEXT(' '), 0 };
545 ConvertUInt32ToString(NSystem::GetNumberOfProcessors(), s + 2);
546 SetItemText(IDT_COMPRESS_HARDWARE_THREADS, s);
547
548 CheckButton(IDX_COMPRESS_SHARED, Info.OpenShareForWrite); 542 CheckButton(IDX_COMPRESS_SHARED, Info.OpenShareForWrite);
549 CheckButton(IDX_COMPRESS_DEL, Info.DeleteAfterCompressing); 543 CheckButton(IDX_COMPRESS_DEL, Info.DeleteAfterCompressing);
550 544
@@ -653,7 +647,19 @@ void CCompressDialog::EnableMultiCombo(unsigned id)
653 EnableItem(id, enable); 647 EnableItem(id, enable);
654} 648}
655 649
656static LRESULT ComboBox_AddStringAscii(NControl::CComboBox &cb, const char *s); 650static LRESULT ComboBox_AddStringAscii(NControl::CComboBox &cb, const char *s)
651{
652 return cb.AddString((CSysString)s);
653}
654
655static LRESULT ComboBox_AddStringAscii_SetItemData(NControl::CComboBox &cb,
656 const char *s, LPARAM lParam)
657{
658 const LRESULT index = ComboBox_AddStringAscii(cb, s);
659 if (index >= 0) // optional check
660 cb.SetItemData((int)index, lParam);
661 return index;
662}
657 663
658static void Combine_Two_BoolPairs(const CBoolPair &b1, const CBoolPair &b2, CBool1 &res) 664static void Combine_Two_BoolPairs(const CBoolPair &b1, const CBoolPair &b2, CBool1 &res)
659{ 665{
@@ -1604,20 +1610,14 @@ void CCompressDialog::SetLevel2()
1604 AddLangString(s, langID); 1610 AddLangString(s, langID);
1605 } 1611 }
1606 } 1612 }
1607 const int index = (int)m_Level.AddString(s); 1613 m_Level.AddString_SetItemData(s, (LPARAM)i);
1608 m_Level.SetItemData(index, (LPARAM)i);
1609 } 1614 }
1610 } 1615 }
1611 SetNearestSelectComboBox(m_Level, level); 1616 SetNearestSelectComboBox(m_Level, level);
1612} 1617}
1613 1618
1614 1619
1615static LRESULT ComboBox_AddStringAscii(NControl::CComboBox &cb, const char *s) 1620static const char * const k_Auto_Prefix = "* ";
1616{
1617 return cb.AddString((CSysString)s);
1618}
1619
1620static const char *k_Auto_Prefix = "* ";
1621 1621
1622static void Modify_Auto(AString &s) 1622static void Modify_Auto(AString &s)
1623{ 1623{
@@ -1690,8 +1690,8 @@ void CCompressDialog::SetMethod2(int keepMethodId)
1690 writtenMethodId = -1; 1690 writtenMethodId = -1;
1691 Modify_Auto(s); 1691 Modify_Auto(s);
1692 } 1692 }
1693 const int itemIndex = (int)ComboBox_AddStringAscii(m_Method, s); 1693 const int itemIndex = (int)ComboBox_AddStringAscii_SetItemData(m_Method,
1694 m_Method.SetItemData(itemIndex, writtenMethodId); 1694 s, writtenMethodId);
1695 if (keepMethodId == methodID) 1695 if (keepMethodId == methodID)
1696 { 1696 {
1697 m_Method.SetCurSel(itemIndex); 1697 m_Method.SetCurSel(itemIndex);
@@ -1731,7 +1731,7 @@ void CCompressDialog::SetEncryptionMethod()
1731 } 1731 }
1732 else if (ai.Is_Zip()) 1732 else if (ai.Is_Zip())
1733 { 1733 {
1734 int index = FindRegistryFormat(ai.Name); 1734 const int index = FindRegistryFormat(ai.Name);
1735 UString encryptionMethod; 1735 UString encryptionMethod;
1736 if (index >= 0) 1736 if (index >= 0)
1737 { 1737 {
@@ -1836,9 +1836,7 @@ static int Combo_AddDict2(NWindows::NControl::CComboBox &cb, size_t sizeReal, si
1836 s.Add_Char('B'); 1836 s.Add_Char('B');
1837 if (sizeReal == k_Auto_Dict) 1837 if (sizeReal == k_Auto_Dict)
1838 Modify_Auto(s); 1838 Modify_Auto(s);
1839 const int index = (int)ComboBox_AddStringAscii(cb, s); 1839 return (int)ComboBox_AddStringAscii_SetItemData(cb, s, (LPARAM)sizeReal);
1840 cb.SetItemData(index, (LPARAM)sizeReal);
1841 return index;
1842} 1840}
1843 1841
1844int CCompressDialog::AddDict2(size_t sizeReal, size_t sizeShow) 1842int CCompressDialog::AddDict2(size_t sizeReal, size_t sizeShow)
@@ -2201,9 +2199,7 @@ int CCompressDialog::AddOrder(UInt32 size)
2201{ 2199{
2202 char s[32]; 2200 char s[32];
2203 ConvertUInt32ToString(size, s); 2201 ConvertUInt32ToString(size, s);
2204 const int index = (int)ComboBox_AddStringAscii(m_Order, s); 2202 return (int)ComboBox_AddStringAscii_SetItemData(m_Order, s, (LPARAM)size);
2205 m_Order.SetItemData(index, (LPARAM)size);
2206 return index;
2207} 2203}
2208 2204
2209int CCompressDialog::AddOrder_Auto() 2205int CCompressDialog::AddOrder_Auto()
@@ -2211,9 +2207,7 @@ int CCompressDialog::AddOrder_Auto()
2211 AString s; 2207 AString s;
2212 s.Add_UInt32(_auto_Order); 2208 s.Add_UInt32(_auto_Order);
2213 Modify_Auto(s); 2209 Modify_Auto(s);
2214 int index = (int)ComboBox_AddStringAscii(m_Order, s); 2210 return (int)ComboBox_AddStringAscii_SetItemData(m_Order, s, (LPARAM)(INT_PTR)(-1));
2215 m_Order.SetItemData(index, (LPARAM)(INT_PTR)(-1));
2216 return index;
2217} 2211}
2218 2212
2219void CCompressDialog::SetOrder2() 2213void CCompressDialog::SetOrder2()
@@ -2490,9 +2484,7 @@ void CCompressDialog::SetSolidBlockSize2()
2490 AString s; 2484 AString s;
2491 Add_Size(s, _auto_Solid); 2485 Add_Size(s, _auto_Solid);
2492 Modify_Auto(s); 2486 Modify_Auto(s);
2493 const int index = (int)ComboBox_AddStringAscii(m_Solid, s); 2487 curSel = (int)ComboBox_AddStringAscii_SetItemData(m_Solid, s, (LPARAM)(UInt32)(Int32)-1);
2494 m_Solid.SetItemData(index, (LPARAM)(UInt32)(Int32)-1);
2495 curSel = index;
2496 } 2488 }
2497 2489
2498 if (is7z) 2490 if (is7z)
@@ -2501,8 +2493,7 @@ void CCompressDialog::SetSolidBlockSize2()
2501 // kSolidLog_NoSolid = 0 for xz means default blockSize 2493 // kSolidLog_NoSolid = 0 for xz means default blockSize
2502 if (is7z) 2494 if (is7z)
2503 LangString(IDS_COMPRESS_NON_SOLID, s); 2495 LangString(IDS_COMPRESS_NON_SOLID, s);
2504 const int index = (int)m_Solid.AddString(s); 2496 const int index = (int)m_Solid.AddString_SetItemData(s, (LPARAM)(UInt32)kSolidLog_NoSolid);
2505 m_Solid.SetItemData(index, (LPARAM)(UInt32)kSolidLog_NoSolid);
2506 if (defaultBlockSize == kSolidLog_NoSolid) 2497 if (defaultBlockSize == kSolidLog_NoSolid)
2507 curSel = index; 2498 curSel = index;
2508 } 2499 }
@@ -2511,16 +2502,15 @@ void CCompressDialog::SetSolidBlockSize2()
2511 { 2502 {
2512 AString s; 2503 AString s;
2513 Add_Size(s, (UInt64)1 << i); 2504 Add_Size(s, (UInt64)1 << i);
2514 const int index = (int)ComboBox_AddStringAscii(m_Solid, s); 2505 const int index = (int)ComboBox_AddStringAscii_SetItemData(m_Solid, s, (LPARAM)(UInt32)i);
2515 m_Solid.SetItemData(index, (LPARAM)(UInt32)i);
2516 if (defaultBlockSize != (UInt32)(Int32)-1) 2506 if (defaultBlockSize != (UInt32)(Int32)-1)
2517 if (i <= defaultBlockSize || index <= 1) 2507 if (i <= defaultBlockSize || index <= 1)
2518 curSel = index; 2508 curSel = index;
2519 } 2509 }
2520 2510
2521 { 2511 {
2522 const int index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_SOLID)); 2512 const int index = (int)m_Solid.AddString_SetItemData(
2523 m_Solid.SetItemData(index, (LPARAM)kSolidLog_FullSolid); 2513 LangString(IDS_COMPRESS_SOLID), (LPARAM)kSolidLog_FullSolid);
2524 if (defaultBlockSize == kSolidLog_FullSolid) 2514 if (defaultBlockSize == kSolidLog_FullSolid)
2525 curSel = index; 2515 curSel = index;
2526 } 2516 }
@@ -2564,7 +2554,7 @@ static bool Is_Zstd_Mt_Supported()
2564} 2554}
2565*/ 2555*/
2566 2556
2567static const char *k_ST_Threads = " (ST)"; 2557static const char * const k_ST_Threads = " (ST)";
2568 2558
2569void CCompressDialog::SetNumThreads2() 2559void CCompressDialog::SetNumThreads2()
2570{ 2560{
@@ -2575,15 +2565,31 @@ void CCompressDialog::SetNumThreads2()
2575 if (!fi.MultiThread_()) 2565 if (!fi.MultiThread_())
2576 return; 2566 return;
2577 2567
2578 const UInt32 numHardwareThreads = NSystem::GetNumberOfProcessors(); 2568 UInt32 numCPUs = 1; // process threads
2579 // 64; // for debug: 2569 UInt32 numHardwareThreads = 1; // system threads
2570 NSystem::CProcessAffinity threadsInfo;
2571 threadsInfo.InitST();
2572#ifndef Z7_ST
2573 threadsInfo.Get_and_return_NumProcessThreads_and_SysThreads(numCPUs, numHardwareThreads);
2574#endif
2580 2575
2581 UInt32 defaultValue = numHardwareThreads; 2576 AString s ("/ ");
2577 {
2578 s.Add_UInt32(numCPUs);
2579 if (numCPUs != numHardwareThreads)
2580 {
2581 s += " / ";
2582 s.Add_UInt32(numHardwareThreads);
2583 }
2584 SetItemTextA(IDT_COMPRESS_HARDWARE_THREADS, s.Ptr());
2585 }
2586
2587 UInt32 defaultValue = numCPUs;
2582 bool useAutoThreads = true; 2588 bool useAutoThreads = true;
2583 2589
2584 { 2590 {
2585 const CArcInfoEx &ai = Get_ArcInfoEx(); 2591 const CArcInfoEx &ai = Get_ArcInfoEx();
2586 int index = FindRegistryFormat(ai.Name); 2592 const int index = FindRegistryFormat(ai.Name);
2587 if (index >= 0) 2593 if (index >= 0)
2588 { 2594 {
2589 const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; 2595 const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
@@ -2597,19 +2603,19 @@ void CCompressDialog::SetNumThreads2()
2597 2603
2598 // const UInt32 num_ZSTD_threads_MAX = Is_Zstd_Mt_Supported() ? MY_ZSTDMT_NBWORKERS_MAX : 0; 2604 // const UInt32 num_ZSTD_threads_MAX = Is_Zstd_Mt_Supported() ? MY_ZSTDMT_NBWORKERS_MAX : 0;
2599 2605
2600 UInt32 numAlgoThreadsMax = numHardwareThreads * 2;
2601 const int methodID = GetMethodID(); 2606 const int methodID = GetMethodID();
2602
2603 const bool isZip = IsZipFormat(); 2607 const bool isZip = IsZipFormat();
2608
2609 UInt32 numAlgoThreadsMax = numHardwareThreads * 2; // for unknow methods
2604 if (isZip) 2610 if (isZip)
2605 numAlgoThreadsMax = 2611 numAlgoThreadsMax =
2606 8 << (sizeof(size_t) / 2); // 32 threads for 32-bit : 128 threads for 64-bit 2612 8 << (sizeof(size_t) / 2); // 32 threads for 32-bit : 128 threads for 64-bit
2607 else if (IsXzFormat()) 2613 else if (IsXzFormat())
2608 numAlgoThreadsMax = 256 * 2; 2614 numAlgoThreadsMax = 256 * 2; // MTCODER_THREADS_MAX * 2
2609 else switch (methodID) 2615 else switch (methodID)
2610 { 2616 {
2611 case kLZMA: numAlgoThreadsMax = 2; break; 2617 case kLZMA: numAlgoThreadsMax = 2; break;
2612 case kLZMA2: numAlgoThreadsMax = 256; break; 2618 case kLZMA2: numAlgoThreadsMax = 256 * 2; break; // MTCODER_THREADS_MAX * 2
2613 case kBZip2: numAlgoThreadsMax = 64; break; 2619 case kBZip2: numAlgoThreadsMax = 64; break;
2614 // case kZSTD: numAlgoThreadsMax = num_ZSTD_threads_MAX; break; 2620 // case kZSTD: numAlgoThreadsMax = num_ZSTD_threads_MAX; break;
2615 case kCopy: 2621 case kCopy:
@@ -2619,9 +2625,9 @@ void CCompressDialog::SetNumThreads2()
2619 case kPPMdZip: 2625 case kPPMdZip:
2620 numAlgoThreadsMax = 1; 2626 numAlgoThreadsMax = 1;
2621 } 2627 }
2622 UInt32 autoThreads = numHardwareThreads; 2628 UInt32 autoThreads = numCPUs;
2623 if (autoThreads > numAlgoThreadsMax) 2629 if (autoThreads > numAlgoThreadsMax)
2624 autoThreads = numAlgoThreadsMax; 2630 autoThreads = numAlgoThreadsMax;
2625 2631
2626 const UInt64 memUse_Limit = Get_MemUse_Bytes(); 2632 const UInt64 memUse_Limit = Get_MemUse_Bytes();
2627 2633
@@ -2676,13 +2682,12 @@ void CCompressDialog::SetNumThreads2()
2676 2682
2677 int curSel = -1; 2683 int curSel = -1;
2678 { 2684 {
2679 AString s; 2685 s.Empty();
2680 s.Add_UInt32(autoThreads); 2686 s.Add_UInt32(autoThreads);
2681 if (autoThreads == 0) s += k_ST_Threads; 2687 if (autoThreads == 0) s += k_ST_Threads;
2682 Modify_Auto(s); 2688 Modify_Auto(s);
2683 const int index = (int)ComboBox_AddStringAscii(m_NumThreads, s); 2689 const int index = (int)ComboBox_AddStringAscii_SetItemData(m_NumThreads,
2684 m_NumThreads.SetItemData(index, (LPARAM)(INT_PTR)(-1)); 2690 s, (LPARAM)(INT_PTR)(-1));
2685 // m_NumThreads.SetItemData(index, autoThreads);
2686 if (useAutoThreads) 2691 if (useAutoThreads)
2687 curSel = index; 2692 curSel = index;
2688 } 2693 }
@@ -2693,11 +2698,11 @@ void CCompressDialog::SetNumThreads2()
2693 1; 2698 1;
2694 i <= numHardwareThreads * 2 && i <= numAlgoThreadsMax; i++) 2699 i <= numHardwareThreads * 2 && i <= numAlgoThreadsMax; i++)
2695 { 2700 {
2696 AString s; 2701 s.Empty();
2697 s.Add_UInt32(i); 2702 s.Add_UInt32(i);
2698 if (i == 0) s += k_ST_Threads; 2703 if (i == 0) s += k_ST_Threads;
2699 const int index = (int)ComboBox_AddStringAscii(m_NumThreads, s); 2704 const int index = (int)ComboBox_AddStringAscii_SetItemData(m_NumThreads,
2700 m_NumThreads.SetItemData(index, (LPARAM)(UInt32)i); 2705 s, (LPARAM)(UInt32)i);
2701 if (!useAutoThreads && i == defaultValue) 2706 if (!useAutoThreads && i == defaultValue)
2702 curSel = index; 2707 curSel = index;
2703 } 2708 }
@@ -2754,9 +2759,7 @@ int CCompressDialog::AddMemComboItem(UInt64 val, bool isPercent, bool isDefault)
2754 sRegistry.DeleteBack(); 2759 sRegistry.DeleteBack();
2755 } 2760 }
2756 const unsigned dataIndex = _memUse_Strings.Add(sRegistry); 2761 const unsigned dataIndex = _memUse_Strings.Add(sRegistry);
2757 const int index = (int)m_MemUse.AddString(sUser); 2762 return (int)m_MemUse.AddString_SetItemData(sUser, (LPARAM)dataIndex);
2758 m_MemUse.SetItemData(index, (LPARAM)dataIndex);
2759 return index;
2760} 2763}
2761 2764
2762 2765
@@ -3439,11 +3442,7 @@ static const unsigned kTimePrec_1ns = 3;
3439static void AddTimeOption(UString &s, UInt32 val, const UString &unit, const char *sys = NULL) 3442static void AddTimeOption(UString &s, UInt32 val, const UString &unit, const char *sys = NULL)
3440{ 3443{
3441 // s += " : "; 3444 // s += " : ";
3442 { 3445 s.Add_UInt32(val);
3443 AString s2;
3444 s2.Add_UInt32(val);
3445 s += s2;
3446 }
3447 s.Add_Space(); 3446 s.Add_Space();
3448 s += unit; 3447 s += unit;
3449 if (sys) 3448 if (sys)
@@ -3476,9 +3475,7 @@ int COptionsDialog::AddPrec(unsigned prec, bool isDefault)
3476 } 3475 }
3477 else 3476 else
3478 s.Add_UInt32(prec); 3477 s.Add_UInt32(prec);
3479 const int index = (int)m_Prec.AddString(s); 3478 return (int)m_Prec.AddString_SetItemData(s, (LPARAM)writePrec);
3480 m_Prec.SetItemData(index, (LPARAM)writePrec);
3481 return index;
3482} 3479}
3483 3480
3484 3481