Skip to content

Commit

Permalink
Merge branch 'kernels'
Browse files Browse the repository at this point in the history
  • Loading branch information
veox committed Jan 26, 2014
2 parents 67d15f2 + e8978db commit cae071b
Show file tree
Hide file tree
Showing 14 changed files with 3,579 additions and 878 deletions.
9 changes: 8 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Authors

## Current
## Core

* Scrypt-only refactor and maintenance: Noel Maersk <veox@wemakethings.net> LfxRFgXzA13TSTxgFGUFEtumv5ShGzAmLw
* Core: Martin Danielsen <kalroth@gmail.com> 1DNBcSEENBwDKrcTyTW61ezWhzsPy5imkn
Expand All @@ -9,6 +9,13 @@
* API: Andrew Smith <kan0i {at} kano-kun [dot] net> 1Jjk2LmktEQKnv8r2cZ9MvLiZwZ9gxabKm


## OpenCL kernels

* scrypt: Colin Percival
* zuikkis: Zuikkis LeXck7EYgxyjw13zNDxZFmmgmWffFvhmSh
* alexkarnew/alexkarold: Alexey Karimov LMqRcHdwnZtTMH6c2kWoxSoKM5KySfaP5C


## Bug fixes

* Gabriel Devenyi
Expand Down
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sgminer_SOURCES += ocl.c ocl.h
sgminer_SOURCES += findnonce.c findnonce.h
sgminer_SOURCES += adl.c adl.h adl_functions.h
sgminer_SOURCES += scrypt.c scrypt.h
sgminer_SOURCES += *.cl
sgminer_SOURCES += kernel/*.cl

bin_SCRIPTS = $(top_srcdir)/*.cl
bin_SCRIPTS = $(top_srcdir)/kernel/*.cl

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ License: GPLv3. See `COPYING` for details.
Documentation is available in directory `doc`. For details on several topics, see:

* `API` for the RPC API specification;
* `SCRYPT` for how to find the right balance in GPU configuration to mine Scrypt-based coins effectively;
* `FAQ` for frequently asked questions;
* `GPU` for semi-obsolete information on GPU configuration options and mining SHA256d-based coins;
* `KERNEL.md` for OpenCL kernel-related information;
* `MINING` for how to find the right balance in GPU configuration to mine Scrypt-based coins effectively;
* `windows-build.txt` for information on how to build on Windows.

Note that **most of the documentation is outdated**. If you want to contribute, fork this repository, update as needed, and submit a pull request.
Expand Down
6 changes: 4 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,10 @@ fi

AC_DEFINE_UNQUOTED([SGMINER_PREFIX], ["$prefix/bin"], [Path to sgminer install])

AC_DEFINE_UNQUOTED([SCRYPT_KERNNAME], ["scrypt130511"], [Filename for scrypt kernel])

AC_DEFINE_UNQUOTED([ALEXKARNEW_KERNNAME], ["alexkarnew"], [Filename for Alexey Karimov's optimised kernel for Catalyst >=13.4])
AC_DEFINE_UNQUOTED([ALEXKAROLD_KERNNAME], ["alexkarold"], [Filename for Alexey Karimov's optimised kernel for Catalyst <13.4])
AC_DEFINE_UNQUOTED([CKOLIVAS_KERNNAME], ["ckolivas"], [Filename for original scrypt kernel])
AC_DEFINE_UNQUOTED([ZUIKKIS_KERNNAME], ["zuikkis"], [Filename for Zuikkis' optimised kernel])

AC_SUBST(OPENCL_LIBS)
AC_SUBST(OPENCL_FLAGS)
Expand Down
86 changes: 86 additions & 0 deletions doc/KERNEL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Kernels

## Available OpenCL kernels

See directory `kernel`.


## Parameter configuration

### Common

In general, switching kernels requires reconfiguring mining parameters,
such as (but not necessarily limited to) `thread-concurrency`, `intensity`,
`gpu-engine` and `gpu-memclock`.

A description of how to do this is available in `doc/MINING`.


### alexkarnew

Alaxey Karimov's optimised kernel, based on `ckolivas`. For Catalyst >=13.4.

Only supports `vectors=1`.

[Announcement](https://litecointalk.org/index.php?topic=4082.0).


### alexkarold

Alaxey Karimov's optimised kernel, based on `ckolivas`. For Catalyst <13.4.

Only supports `vectors=1`.

[Announcement](https://litecointalk.org/index.php?topic=4082.0).


### ckolivas

The original Colin Percival `scrypt` kernel, maintained for a long time by
Con Kolivas in `cgminer` and renamed to reflect the fact.

Only supports `vectors=1`.


### zuikkis

Zuikkis' optimised kernel, based on `ckolivas`.

Only supports `vectors=1`, `lookup-gap=2` and `worksize=256`.

[Announcement](https://litecointalk.org/index.php?topic=6058.msg90873#msg90873).


## Submitting new kernels

### Requirements

* OpenCL source code only, licenced under GPLv3 (or later).
* Not hard-coded for a specific GPU model or manufacturer.
* Known limitations and any specific configuration quirks must be mentioned.


### Procedure

1. Copy the kernel you wish to modify and commit it verbatim.

This way, it is easy to verify that there are no hidden changes. Note in
the commit message which kernel is used as a base.

2. Make changes to the kernel. Commit them.

This allows to produce a diff that makes sense.

3. Search for KL_CKOLIVAS and CKOLIVAS_KERNNAME in the top-level source
directory and make additions to the listed files in order to integrate
the new kernel.

Now it can be selected when starting via the `--kernel` argument or
`kernel` configuration option.

4. Add yourself to the "kernels" section in `AUTHORS.md`. Keep it short.

5. Submit a pull request on GitHub, or file it at the issue tracker,
outlining the changes made, known limitations, and tested GPUs. List
your git repository and branch name. The current repository and issue
tracker links should be in `README.md`.
File renamed without changes.
37 changes: 28 additions & 9 deletions driver-opencl.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,14 @@ char *set_thread_concurrency(char *arg)

static enum cl_kernels select_kernel(char *arg)
{
if (!strcmp(arg, "scrypt"))
return KL_SCRYPT;
if (!strcmp(arg, ALEXKARNEW_KERNNAME))
return KL_ALEXKARNEW;
if (!strcmp(arg, ALEXKAROLD_KERNNAME))
return KL_ALEXKAROLD;
if (!strcmp(arg, CKOLIVAS_KERNNAME))
return KL_CKOLIVAS;
if (!strcmp(arg, ZUIKKIS_KERNNAME))
return KL_ZUIKKIS;

return KL_NONE;
}
Expand Down Expand Up @@ -1291,8 +1297,17 @@ static bool opencl_thread_prepare(struct thr_info *thr)
if (!cgpu->kname)
{
switch (clStates[i]->chosen_kernel) {
case KL_SCRYPT:
cgpu->kname = "scrypt";
case KL_ALEXKARNEW:
cgpu->kname = ALEXKARNEW_KERNNAME;
break;
case KL_ALEXKAROLD:
cgpu->kname = ALEXKAROLD_KERNNAME;
break;
case KL_CKOLIVAS:
cgpu->kname = CKOLIVAS_KERNNAME;
break;
case KL_ZUIKKIS:
cgpu->kname = ZUIKKIS_KERNNAME;
break;
default:
break;
Expand Down Expand Up @@ -1322,11 +1337,15 @@ static bool opencl_thread_init(struct thr_info *thr)
}

switch (clState->chosen_kernel) {
case KL_SCRYPT:
thrdata->queue_kernel_parameters = &queue_scrypt_kernel;
break;
default:
break;
case KL_ALEXKARNEW:
case KL_ALEXKAROLD:
case KL_CKOLIVAS:
case KL_ZUIKKIS:
thrdata->queue_kernel_parameters = &queue_scrypt_kernel;
break;
default:
applog(LOG_ERR, "Failed to choose kernel in opencl_thread_init");
break;
}

thrdata->res = calloc(buffersize, 1);
Expand Down
Loading

0 comments on commit cae071b

Please sign in to comment.