@@ -638,21 +638,36 @@ static cl_int queue_whirlcoin_kernel(struct __clState *clState, struct _dev_blk_
638
638
639
639
static cl_int queue_whirlpoolx_kernel (struct __clState * clState , struct _dev_blk_ctx * blk , __maybe_unused cl_uint threads )
640
640
{
641
- cl_kernel * kernel ;
641
+ uint64_t midblock [ 8 ], key [ 8 ] = { 0 }, tmp [ 8 ] = { 0 } ;
642
642
cl_ulong le_target ;
643
- cl_int status = 0 ;
643
+ cl_int status ;
644
644
645
645
le_target = * (cl_ulong * )(blk -> work -> device_target + 24 );
646
646
flip80 (clState -> cldata , blk -> work -> data );
647
- status = clEnqueueWriteBuffer (clState -> commandQueue , clState -> CLbuffer0 , true, 0 , 80 , clState -> cldata , 0 , NULL , NULL );
648
647
649
- //clbuffer, hashes
650
- kernel = & clState -> kernel ;
651
- CL_SET_ARG_N (0 , clState -> CLbuffer0 );
652
- CL_SET_ARG_N (1 , clState -> padbuffer8 );
648
+ memcpy (midblock , clState -> cldata , 64 );
653
649
654
- CL_SET_ARG_N (2 , clState -> outputBuffer );
655
- CL_SET_ARG_N (3 , le_target );
650
+ // midblock = n, key = h
651
+ for (int i = 0 ; i < 10 ; ++ i ) {
652
+ tmp [0 ] = WHIRLPOOL_ROUND_CONSTANTS [i ];
653
+ whirlpool_round (key , tmp );
654
+ tmp [0 ] = 0 ;
655
+ whirlpool_round (midblock , tmp );
656
+
657
+ for (int x = 0 ; x < 8 ; ++ x ) {
658
+ midblock [x ] ^= key [x ];
659
+ }
660
+ }
661
+
662
+ for (int i = 0 ; i < 8 ; ++ i ) {
663
+ midblock [i ] ^= ((uint64_t * )(clState -> cldata ))[i ];
664
+ }
665
+
666
+ status = clSetKernelArg (clState -> kernel , 0 , sizeof (cl_ulong8 ), (cl_ulong8 * )& midblock );
667
+ status |= clSetKernelArg (clState -> kernel , 1 , sizeof (cl_ulong ), (void * )(((uint64_t * )clState -> cldata ) + 8 ));
668
+ status |= clSetKernelArg (clState -> kernel , 2 , sizeof (cl_ulong ), (void * )(((uint64_t * )clState -> cldata ) + 9 ));
669
+ status |= clSetKernelArg (clState -> kernel , 3 , sizeof (cl_mem ), (void * )& clState -> outputBuffer );
670
+ status |= clSetKernelArg (clState -> kernel , 4 , sizeof (cl_ulong ), (void * )& le_target );
656
671
657
672
return status ;
658
673
}
@@ -720,27 +735,6 @@ static cl_int queue_pluck_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_un
720
735
return status ;
721
736
}
722
737
723
- typedef struct _algorithm_settings_t {
724
- const char * name ; /* Human-readable identifier */
725
- algorithm_type_t type ; //common algorithm type
726
- const char * kernelfile ; /* alternate kernel file */
727
- double diff_multiplier1 ;
728
- double diff_multiplier2 ;
729
- double share_diff_multiplier ;
730
- uint32_t xintensity_shift ;
731
- uint32_t intensity_shift ;
732
- uint32_t found_idx ;
733
- unsigned long long diff_numerator ;
734
- uint32_t diff1targ ;
735
- size_t n_extra_kernels ;
736
- long rw_buffer_size ;
737
- cl_command_queue_properties cq_properties ;
738
- void (* regenhash )(struct work * );
739
- cl_int (* queue_kernel )(struct __clState * , struct _dev_blk_ctx * , cl_uint );
740
- void (* gen_hash )(const unsigned char * , unsigned int , unsigned char * );
741
- void (* set_compile_options )(build_kernel_data * , struct cgpu_info * , algorithm_t * );
742
- } algorithm_settings_t ;
743
-
744
738
static algorithm_settings_t algos [] = {
745
739
// kernels starting from this will have difficulty calculated by using litecoin algorithm
746
740
#define A_SCRYPT (a ) \
@@ -810,7 +804,7 @@ static algorithm_settings_t algos[] = {
810
804
#undef A_FUGUE
811
805
812
806
{ "whirlcoin" , ALGO_WHIRL , "" , 1 , 1 , 1 , 0 , 0 , 0xFF , 0xFFFFULL , 0x0000ffffUL , 3 , 8 * 16 * 4194304 , CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE , whirlcoin_regenhash , queue_whirlcoin_kernel , sha256 , NULL },
813
- { "whirlpoolx" , ALGO_WHIRL , "" , 1 , 1 , 1 , 0 , 0 , 0xFF , 0xFFFFULL , 0x0000ffffUL , 0 , 0 , 0 , whirlpoolx_regenhash , queue_sph_kernel , gen_hash , NULL },
807
+ { "whirlpoolx" , ALGO_WHIRLPOOLX , "" , 1 , 1 , 1 , 0 , 0 , 0xFFU , 0xFFFFULL , 0x0000FFFFUL , 0 , 0 , 0 , whirlpoolx_regenhash , queue_whirlpoolx_kernel , gen_hash , NULL },
814
808
815
809
// Terminator (do not remove)
816
810
{ NULL , ALGO_UNK , "" , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , NULL , NULL , NULL , NULL }
@@ -883,7 +877,6 @@ static const char *lookup_algorithm_alias(const char *lookup_alias, uint8_t *nfa
883
877
ALGO_ALIAS ("nist5" , "talkcoin-mod" );
884
878
ALGO_ALIAS ("keccak" , "maxcoin" );
885
879
ALGO_ALIAS ("whirlpool" , "whirlcoin" );
886
- ALGO_ALIAS ("whirlpoolx" , "whirlpoolx" );
887
880
ALGO_ALIAS ("Lyra2RE" , "lyra2re" );
888
881
ALGO_ALIAS ("lyra2" , "lyra2re" );
889
882
@@ -945,8 +938,7 @@ void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor)
945
938
}
946
939
}
947
940
948
- bool cmp_algorithm (algorithm_t * algo1 , algorithm_t * algo2 )
941
+ bool cmp_algorithm (const algorithm_t * algo1 , const algorithm_t * algo2 )
949
942
{
950
- // return (strcmp(algo1->name, algo2->name) == 0) && (algo1->nfactor == algo2->nfactor);
951
943
return (!safe_cmp (algo1 -> name , algo2 -> name ) && !safe_cmp (algo1 -> kernelfile , algo2 -> kernelfile ) && (algo1 -> nfactor == algo2 -> nfactor ));
952
944
}
0 commit comments