// Aplica o back-end do juninho @target : mipsjun // Especifica o tipo de metodo empregado para salvar o resultado da compilação //@export : MultCoreJun @export : simulation // Diretorio onde o resultado da compilação será gravado @outputDirectory : `C:\Users\EUGENIO CARVALHO\Desktop\tmp\lu` // Quantidade de palavras de um bloco 32 palavras de 4bytes @cacheBlockSize: `32` /** Profile de compilacao do back-end O formato da string é um json que descreve um array de definições de cada core { "stackBaseAddress" : 5888, -> endereço da base da pilha do core em questão "initFunction": "multiplica(0)", -> define a main de cada core. aceita ate 4 parametros com valores de constantes "id": "core0" -> label que define o codigo de cada core }, Se "stackBaseAddress" não for definido o compilador irá inferir o valor iniciando do ultimo endereço da memoria */ @profile: `[ { "id" : "core0", "initFunction" : "bitCount(0)", "filename" : "%s_core_0.txt" }, { "id" : "core1", "initFunction" : "bitCount(18750)", "filename" : "%s_core_1.txt" }, { "id" : "core2", "initFunction" : "bitCount(37500)", "filename" : "%s_core_2.txt" }, { "id" : "core3", "initFunction" : "bitCount(56250)", "filename" : "%s_core_3.txt" } ]` package main; const ( ArraySize = 8 ) var ( arr [ArraySize]int32 ) /* This function is same in both iterative and recursive*/ func partition(l, h int32) int32 { var ( limit, index, x, i, tmp int32 ) x = arr[h] i = l - 1 for j := l; j < h; j++ { if arr[j] <= x { i++ tmp = arr[i] arr[i] = arr[j] arr[j] = tmp } } index = i + 1 //arr[h], arr[tmp] = , arr[h] tmp = arr[index] arr[index] = arr[h] arr[h] = tmp return i + 1 } func quickSortIterative(l, h int32) { var ( top, p int32 // Create an auxiliary stack stack [ArraySize]int32 // initialize top of stack ) // push initial values of l and h to stack stack[top] = l top++ stack[top] = h // Keep popping from stack while is not empty for top >= 0 { // Pop h and l h = stack[top] top-- l = stack[top] top-- // Set pivot element at its correct position // in sorted array p = partition(l, h) // If there are elements on left side of pivot, // then push left side to stack if p-1 > l { top++ stack[top] = l top++ stack[top] = p - 1 } // If there are elements on right side of pivot, // then push right side to stack if p+1 < h { top++ stack[top] = p + 1 top++ stack[top] = h } } } // Driver program to test above functions func main() { /* arr[0] = 4 arr[1] = 3 arr[2] = 5 arr[3] = 2 arr[4] = 1 arr[5] = 3 arr[6] = 2 arr[7] = 3 */ size := ArraySize - 1 j := 0 for i := size; i > 0; i-- { arr[j] = i j++ } //partition(0,7) quickSortIterative(0, 7) //quickSortIterative(0, 4) //quickSortIterative(4, 7) }