Skip to content

Commit

Permalink
Merge pull request #17 from ixfd64/refactor_1
Browse files Browse the repository at this point in the history
0.15pre7 refactor
  • Loading branch information
k3ack3r authored May 5, 2020
2 parents ca785d6 + 837c3dc commit 8831938
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 71 deletions.
24 changes: 20 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
# build artifacts
*.o
*.obj
*~

# binaries
mfakto
*.obj
*.elf
*.exe

# copied from source directory
*.cl
!src/*.cl
*.h
!src/*.h
*.ini
!src/*.ini

# machine-specific Visual Studio files
*.suo
*.sdf
*.opensdf
*.vcxproj.user
*.ini
!src/*.ini
*.exe

# Visual Studio build folders
ipch/
Release/
Debug/
x64/

# instance-specific files
*.ckp
*.ckp.bu
results.txt
worktodo.txt
66 changes: 37 additions & 29 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
** Preface for mfakto 0.15pre6 **
** Preface for mfakto 0.15pre7 **

This is a developmental version of mfakto. It has been verified to produce
correct results. However, performance has not been optimized and there may be
Expand Down Expand Up @@ -44,8 +44,8 @@ Contents

mfakto is an OpenCL port of mfaktc that aims to have the same features and
functions. mfaktc is a program that trial factors Mersenne numbers. It stands
for "Mersenne faktorisation* with CUDA" and was written for Nvidia GPUs. mfakto
is used primarily in the Great Internet Mersenne Prime Search.
for "Mersenne faktorisation* with CUDA" and was written for Nvidia GPUs. Both
programs are used primarily in the Great Internet Mersenne Prime Search.

Primality tests are computationally intensive, but we can save time by finding
small factors. GPUs are very efficient at this task due to their parallel
Expand All @@ -58,6 +58,7 @@ mfakto can perform both steps on either the CPU or GPU. You can find more
details at the GIMPS website:
https://mersenne.org/various/math.php#trial_factoring


* portmanteau of the English word "factorisation" and the German word
"Faktorisierung"

Expand All @@ -70,9 +71,9 @@ General requirements:
- C and C++ development tools
- an OpenCL SDK

Please note: the AMD APP SDK has been discontinued. If you still decide to use
it to compile mfakto, make sure you have version 2.5 or later. You can download
the AMD APP SDK here: https://community.amd.com/thread/227948
Please note: the AMD APP SDK has been discontinued. If you still want to use it
to compile mfakto, make sure you have version 2.5 or later. You can download
the SDK here: https://community.amd.com/thread/227948

#############
# 1.1 Linux #
Expand Down Expand Up @@ -102,19 +103,20 @@ Steps:
- install the GPUOpen OpenCL SDK
- launch Visual Studio and open the mfaktoVS12.sln file. You can use a later
version as Visual Studio will automatically convert your projects. If the
option does not appear, then right-click the solution and select "Retarget
option does not appear, right-click the solution and select "Retarget
solution" from the menu.
- open the project properties and select the configuration and platform
- go to C/C++ > General > Additional Include Directories and add the path to
the OpenCL headers:

%OCL_ROOT%\include
$(OCL_ROOT)\include

- then go to Linker > General > Additional Library Directories and add the path
to the appropriate library folder:
- now go to Linker > General > Additional Library Directories and add the path
to the appropriate library folder. You may need to restart your computer for
Visual Studio to recognize the OCL_ROOT system variable.

32-bit -> %OCL_ROOT%\lib\x86
64-bit -> %OCL_ROOT%\lib\x86_64
32 bits: $(OCL_ROOT)\lib\x86
64 bits: $(OCL_ROOT)\lib\x86_64

- select Build > Build Solution to compile mfakto

Expand Down Expand Up @@ -165,14 +167,17 @@ Steps:
- mfakto should compile out of the box as macOS contains a native OpenCL
implementation

You may see some warnings, but they are safe to ignore.

####################
# 2 Running mfakto #
####################

General requirements:
- AMD Catalyst 11.4 or higher. Consider using 11.10 or above as the AMD APP SDK
has been discontinued.
- otherwise: AMD APP SDK 2.5 or higher
- AMD Catalyst 11.4 or higher. Consider using 14.4 or above as previous
versions have a bug that causes high CPU loads.
- AMD APP SDK 2.5 or higher unless using AMD Catalyst 11.10 or above. However,
this is not recommended as the AMD APP SDK has been discontinued.
- for Intel integrated GPUs: Compute Runtime for OpenCL

macOS users do not need any additional software as OpenCL is already part of
Expand All @@ -185,12 +190,13 @@ obtain assignments and report results.

A typical worktodo.txt file looks like this:
-- begin example --
Factor=[...],66362159,64,68
Factor=[...],3321932899,76,77
Factor=[assignment ID],66362159,64,68
Factor=[assignment ID],3321932899,76,77
-- end example --

You can launch mfakto after getting assignments. It should trial factor
M66362159 from 64 to 68 bits, followed by M3321932899 from 76 to 77 bits.
You can launch mfakto after getting assignments. In this case, mfakto should
trial factor M66362159 from 64 to 68 bits, followed by M3321932899 from 76 to
77 bits.

mfakto has a built-in self-test that automatically optimizes parameters. Please
run 'mfakto -st' each time you:
Expand Down Expand Up @@ -235,19 +241,21 @@ either the '-d c' option or Prime95 / mprime.
###############

Requirements:
- AMD Catalyst 11.4 is the minimum required version. Consider using 11.10 or
above as the AMD APP SDK has been discontinued.
- otherwise: AMD APP SDK 2.5 or higher. In this case, make sure the path to the
appropriate library folder is in the system Path variable:
- AMD Catalyst 11.4 is the minimum required version. Consider using 14.4 or
above as previous versions have a bug that causes high CPU loads.
- AMD APP SDK 2.5 or higher unless using AMD Catalyst 11.10 or above. However,
this is not recommended as the AMD APP SDK has been discontinued. If you
still want to use it to compile mfakto, make sure the path to the appropriate
library folder is in the system Path variable:

32-bit -> %AMDAPPSDKROOT%\lib\x86
64-bit -> %AMDAPPSDKROOT%\lib\x86_64
32 bits: %AMDAPPSDKROOT%\lib\x86
64 bits: %AMDAPPSDKROOT%\lib\x86_64

- you may need the Microsoft Visual C++ 2010 Redistributable Package for your
platform and language:

32-bit -> https://microsoft.com/en-us/download/details.aspx?id=5555
64-bit -> https://microsoft.com/en-us/download/details.aspx?id=14632
32 bits: https://microsoft.com/en-us/download/details.aspx?id=5555
64 bits: https://microsoft.com/en-us/download/details.aspx?id=14632

Steps:
- build mfakto using the above instructions or download a stable version. Only
Expand Down Expand Up @@ -301,7 +309,7 @@ From mersenne.ca:
Advanced usage:
As mfakto works best on long-running jobs, you may want to manually extend
your assignments. Let's assume you've received an assignment like this:
Factor=[...],78467119,65,66
Factor=[assignment ID],78467119,65,66

This means the PrimeNet server has assigned you to trial factor M78467119
from 65 to 66 bits. However, take a look at the factoring limits:
Expand All @@ -311,7 +319,7 @@ Advanced usage:
tested. Because mfakto runs very fast on modern GPUs, you might want to go
directly to 71 or even 72 bits. Simply edit the ending bit level before
starting mfakto. For example:
Factor=[...],78467119,65,72
Factor=[assignment ID],78467119,65,72

It is important to submit the results once you're done. Do not report
partial results as the exponent may be reassigned to someone else in the
Expand Down
27 changes: 14 additions & 13 deletions mfaktoVS12.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down Expand Up @@ -73,33 +73,34 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>mfakto</RootNamespace>
<ProjectName>mfakto</ProjectName>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -140,15 +141,15 @@
<WarningLevel>Level1</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BUILD_OPENCL;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Program Files (x86)\AMD APP SDK\3.0\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(OCL_ROOT)\include</AdditionalIncludeDirectories>
<TreatWarningAsError>false</TreatWarningAsError>
<OmitFramePointers>false</OmitFramePointers>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<Version>0.14</Version>
<AdditionalLibraryDirectories>C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(OCL_ROOT)\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>OpenCL.lib</AdditionalDependencies>
</Link>
<PostBuildEvent>
Expand All @@ -171,15 +172,15 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BUILD_OPENCL;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Program Files (x86)\AMD APP SDK\3.0\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(OCL_ROOT)\include</AdditionalIncludeDirectories>
<TreatWarningAsError>false</TreatWarningAsError>
<OmitFramePointers>false</OmitFramePointers>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<Version>0.15</Version>
<AdditionalLibraryDirectories>C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86_64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(OCL_ROOT)\lib\x86_64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
Expand All @@ -204,7 +205,7 @@
<FunctionLevelLinking>false</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BUILD_OPENCL;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Program Files (x86)\AMD APP SDK\3.0\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(OCL_ROOT)\include</AdditionalIncludeDirectories>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
Expand All @@ -222,7 +223,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<Version>0.14</Version>
<AdditionalLibraryDirectories>C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(OCL_ROOT)\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
Expand All @@ -247,7 +248,7 @@
<FunctionLevelLinking>false</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BUILD_OPENCL;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Program Files (x86)\AMD APP SDK\3.0\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(OCL_ROOT)\include</AdditionalIncludeDirectories>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
Expand All @@ -264,7 +265,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<Version>0.14</Version>
<AdditionalLibraryDirectories>C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86_64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(OCL_ROOT)\lib\x86_64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
Expand Down
26 changes: 13 additions & 13 deletions src/mfaktc.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ GPUKernels find_fastest_kernel(mystuff_t *mystuff, cl_uint do_test)
BARRETT87_MUL32,
BARRETT83_MUL15,
BARRETT79_MUL32,
BARRETT88_MUL32,
BARRETT88_MUL32,
BARRETT88_MUL15,
BARRETT92_MUL32,
MG62,
MG62,
_63BIT_MUL24,
_71BIT_MUL24,
_71BIT_MUL24,
MG88,
UNKNOWN_KERNEL,
UNKNOWN_KERNEL },
Expand All @@ -321,12 +321,12 @@ GPUKernels find_fastest_kernel(mystuff_t *mystuff, cl_uint do_test)
BARRETT87_MUL32,
BARRETT83_MUL15,
BARRETT79_MUL32,
BARRETT88_MUL32,
BARRETT88_MUL32,
BARRETT88_MUL15,
BARRETT92_MUL32,
MG62,
MG62,
_63BIT_MUL24,
_71BIT_MUL24,
_71BIT_MUL24,
MG88,
UNKNOWN_KERNEL,
UNKNOWN_KERNEL },
Expand All @@ -343,12 +343,12 @@ GPUKernels find_fastest_kernel(mystuff_t *mystuff, cl_uint do_test)
BARRETT92_MUL32,
BARRETT73_MUL15,
BARRETT74_MUL15,
BARRETT82_MUL15,
BARRETT82_MUL15,
BARRETT83_MUL15,
BARRETT88_MUL15,
MG62,
MG62,
_63BIT_MUL24,
_71BIT_MUL24,
_71BIT_MUL24,
MG88,
UNKNOWN_KERNEL,
UNKNOWN_KERNEL },
Expand All @@ -365,12 +365,12 @@ GPUKernels find_fastest_kernel(mystuff_t *mystuff, cl_uint do_test)
BARRETT83_MUL15,
BARRETT87_MUL32,
BARRETT88_MUL32,
BARRETT79_MUL32,
BARRETT79_MUL32,
BARRETT88_MUL15,
BARRETT92_MUL32,
MG62,
MG62,
_63BIT_MUL24,
_71BIT_MUL24,
_71BIT_MUL24,
MG88,
UNKNOWN_KERNEL,
UNKNOWN_KERNEL },
Expand Down Expand Up @@ -564,7 +564,7 @@ other return value
mystuff->stats.ghzdays = primenet_ghzdays(mystuff->exponent, mystuff->bit_min, mystuff->bit_max_stage);
max_class = mystuff->num_classes-1;

if(mystuff->mode != MODE_SELFTEST_SHORT)printf("Starting trial factoring M%u from 2^%d to 2^%d (%.2fGHz-days)\n",
if(mystuff->mode != MODE_SELFTEST_SHORT)printf("Starting trial factoring M%u from 2^%d to 2^%d (%.2f GHz-days)\n",
mystuff->exponent, mystuff->bit_min, mystuff->bit_max_stage, mystuff->stats.ghzdays);
timer_init(&timer);
time(&time_last_checkpoint);
Expand Down
Loading

0 comments on commit 8831938

Please sign in to comment.