资源简介

中科大程序设计与计算机系统,实验4,代码优化,亲测可用,版本优化相当高

资源截图

代码片段和文件信息

/********************************************************
 * Kernels to be optimized for the CS:APP Performance Lab
 ********************************************************/

#include 
#include 
#include “defs.h“

/*
 * Please fill in the following team struct
 */
team_t team = {
    “Seventh“              /* Team name */

    “SA15226148“     /* First member full name */
    “sa615148@mail.ustc.edu.cn“  /* First member email address */

    “JG15225019“                   /* Second member full name (leave blank if none) */
    “909241007@qq.com“                    /* Second member email addr (leave blank if none) */
};

/***************
 * ROTATE KERNEL
 ***************/

/******************************************************
 * Your different versions of the rotate kernel go here
 ******************************************************/

/*
 * naive_rotate - The naive baseline version of rotate
 */
char naive_rotate_descr[] = “naive_rotate: Naive baseline implementation“;
void naive_rotate(int dim pixel *src pixel *dst)
{
    int i j;

    for (i = 0; i < dim; i++)
for (j = 0; j < dim; j++)
    dst[RIDX(dim-1-j i dim)] = src[RIDX(i j dim)];
}

/*
 * rotate - Your current working version of rotate
 * IMPORTANT: This is the version you will be graded on
 */
char rotate_descr[] = “rotate: Current working version“;
void rotate(int dim pixel *src pixel *dst)
{
    //change here
    int ijk;
    int stride = 32;
    int count = dim >> 5;
    src += dim - 1;
    for (i=0; i        for (j=0; j            for (k=0; k                *dst++ = *src;
                src += dim;
            }
            src -= dim *stride + 1;
            dst += dim - stride;
        }
        src += dim * (stride + 1);
        dst -= dim * dim - stride;
    }
}

/*********************************************************************
 * register_rotate_functions - Register all of your different versions
 *     of the rotate kernel with the driver by calling the
 *     add_rotate_function() for each test function. When you run the
 *     driver program it will test and report the performance of each
 *     registered test function.
 *********************************************************************/

void register_rotate_functions()
{
    add_rotate_function(&naive_rotate naive_rotate_descr);
    add_rotate_function(&rotate rotate_descr);
    /* ... Register additional test functions here */
}


/***************
 * SMOOTH KERNEL
 **************/

/***************************************************************
 * Various typedefs and helper functions for the smooth function
 * You may modify these any way you like.
 **************************************************************/

/* A struct used to compute averaged pixel value */
typedef struct {
    int red;
    int green;
    int blue;
    int num;
} pixel_sum;

/* Compute min and max of two integers respectively */
static int min(int a

评论

共有 条评论